From e5553011f7e6020c8c127627f3907dd75ec10a3b Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Wed, 10 Jul 2024 16:35:57 -0600 Subject: [PATCH] Disable sorting of flags in help text --- cmd/root.go | 7 ++++--- pkg/cmd/dev/cmd.go | 2 ++ pkg/cmd/info/cmd.go | 2 ++ pkg/cmd/inspect/cmd.go | 2 ++ pkg/cmd/list/cmd.go | 1 + pkg/cmd/login/cmd.go | 1 + pkg/cmd/pack/cmd.go | 1 + pkg/cmd/pull/cmd.go | 1 + pkg/cmd/push/cmd.go | 1 + pkg/cmd/remove/cmd.go | 1 + pkg/cmd/unpack/cmd.go | 1 + 11 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index a9caac6e..5a4d31ca 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -103,17 +103,18 @@ func RunCommand() *cobra.Command { }, } addSubcommands(cmd) - cmd.PersistentFlags().StringVar(&opts.configHome, "config", "", "Alternate path to root storage directory for CLI") - cmd.PersistentFlags().CountVarP(&opts.verbosity, "verbose", "v", "Increase verbosity of output (use -vv for more)") cmd.PersistentFlags().StringVar(&opts.loglevel, "log-level", "info", "Log messages above specified level ('trace', 'debug', 'info', 'warn', 'error') (default 'info')") cmd.PersistentFlags().StringVar(&opts.progressBars, "progress", "plain", "Configure progress bars for longer operations (options: none, plain, fancy)") + cmd.PersistentFlags().StringVar(&opts.configHome, "config", "", "Alternate path to root storage directory for CLI") + cmd.PersistentFlags().CountVarP(&opts.verbosity, "verbose", "v", "Increase verbosity of output (use -vv for more)") + cmd.PersistentFlags().SortFlags = false + cmd.Flags().SortFlags = false cmd.SetHelpTemplate(helpTemplate) cmd.SetUsageTemplate(usageTemplate) cobra.AddTemplateFunc("indent", indentBlock) cobra.AddTemplateFunc("sectionHead", sectionHead) cobra.AddTemplateFunc("ensureTrailingNewline", ensureTrailingNewline) - return cmd } diff --git a/pkg/cmd/dev/cmd.go b/pkg/cmd/dev/cmd.go index 89720402..6c72e21b 100644 --- a/pkg/cmd/dev/cmd.go +++ b/pkg/cmd/dev/cmd.go @@ -53,6 +53,8 @@ func DevStartCommand() *cobra.Command { cmd.Flags().StringVarP(&opts.modelFile, "file", "f", "", "Path to the kitfile") cmd.Flags().StringVar(&opts.host, "host", "127.0.0.1", "Host for the development server") cmd.Flags().IntVar(&opts.port, "port", 0, "Port for development server to listen on") + cmd.Flags().SortFlags = false + return cmd } diff --git a/pkg/cmd/info/cmd.go b/pkg/cmd/info/cmd.go index a67202cb..1e32ffce 100644 --- a/pkg/cmd/info/cmd.go +++ b/pkg/cmd/info/cmd.go @@ -70,6 +70,8 @@ func InfoCommand() *cobra.Command { opts.AddNetworkFlags(cmd) cmd.Flags().BoolVarP(&opts.checkRemote, "remote", "r", false, "Check remote registry instead of local storage") + cmd.Flags().SortFlags = false + return cmd } diff --git a/pkg/cmd/inspect/cmd.go b/pkg/cmd/inspect/cmd.go index e99dbad2..fe7f051b 100644 --- a/pkg/cmd/inspect/cmd.go +++ b/pkg/cmd/inspect/cmd.go @@ -70,6 +70,8 @@ func InspectCommand() *cobra.Command { opts.AddNetworkFlags(cmd) cmd.Flags().BoolVarP(&opts.checkRemote, "remote", "r", false, "Check remote registry instead of local storage") + cmd.Flags().SortFlags = false + return cmd } diff --git a/pkg/cmd/list/cmd.go b/pkg/cmd/list/cmd.go index ae1735e9..7855e6f6 100644 --- a/pkg/cmd/list/cmd.go +++ b/pkg/cmd/list/cmd.go @@ -102,6 +102,7 @@ func ListCommand() *cobra.Command { cmd.Args = cobra.MaximumNArgs(1) opts.AddNetworkFlags(cmd) + cmd.Flags().SortFlags = false return cmd } diff --git a/pkg/cmd/login/cmd.go b/pkg/cmd/login/cmd.go index eea66d0a..14ce4e52 100644 --- a/pkg/cmd/login/cmd.go +++ b/pkg/cmd/login/cmd.go @@ -59,6 +59,7 @@ func LoginCommand() *cobra.Command { cmd.Flags().StringVarP(&opts.password, "password", "p", "", "registry password or token") cmd.Flags().BoolVar(&opts.passwordFromStdIn, "password-stdin", false, "read password from stdin") opts.AddNetworkFlags(cmd) + cmd.Flags().SortFlags = false return cmd } diff --git a/pkg/cmd/pack/cmd.go b/pkg/cmd/pack/cmd.go index 7220d986..8cede3b4 100644 --- a/pkg/cmd/pack/cmd.go +++ b/pkg/cmd/pack/cmd.go @@ -65,6 +65,7 @@ func PackCommand() *cobra.Command { cmd.Flags().StringVarP(&opts.modelFile, "file", "f", "", "Specifies the path to the Kitfile explictly (use \"-\" to read from standard input)") cmd.Flags().StringVarP(&opts.fullTagRef, "tag", "t", "", "Assigns one or more tags to the built modelkit. Example: -t registry/repository:tag1,tag2") cmd.Flags().StringVar(&opts.compression, "compression", "none", "Compression format to use for layers. Valid options: 'none' (default), 'gzip', 'gzip-fastest'") + cmd.Flags().SortFlags = false cmd.Args = cobra.ExactArgs(1) return cmd } diff --git a/pkg/cmd/pull/cmd.go b/pkg/cmd/pull/cmd.go index 15150558..d4319d88 100644 --- a/pkg/cmd/pull/cmd.go +++ b/pkg/cmd/pull/cmd.go @@ -82,6 +82,7 @@ func PullCommand() *cobra.Command { cmd.Args = cobra.ExactArgs(1) opts.AddNetworkFlags(cmd) + cmd.Flags().SortFlags = false return cmd } diff --git a/pkg/cmd/push/cmd.go b/pkg/cmd/push/cmd.go index c8911bbe..b927ba2f 100644 --- a/pkg/cmd/push/cmd.go +++ b/pkg/cmd/push/cmd.go @@ -89,6 +89,7 @@ func PushCommand() *cobra.Command { cmd.Args = cobra.ExactArgs(1) opts.AddNetworkFlags(cmd) + cmd.Flags().SortFlags = false return cmd } diff --git a/pkg/cmd/remove/cmd.go b/pkg/cmd/remove/cmd.go index abee72ec..926b57fd 100644 --- a/pkg/cmd/remove/cmd.go +++ b/pkg/cmd/remove/cmd.go @@ -108,6 +108,7 @@ func RemoveCommand() *cobra.Command { cmd.Flags().BoolVarP(&opts.removeAll, "all", "a", false, "remove all untagged modelkits") cmd.Flags().BoolVarP(&opts.remote, "remote", "r", false, "remove modelkit from remote registry") opts.AddNetworkFlags(cmd) + cmd.Flags().SortFlags = false cmd.Args = func(cmd *cobra.Command, args []string) error { switch len(args) { diff --git a/pkg/cmd/unpack/cmd.go b/pkg/cmd/unpack/cmd.go index 6464e068..7d3fbf5b 100644 --- a/pkg/cmd/unpack/cmd.go +++ b/pkg/cmd/unpack/cmd.go @@ -128,6 +128,7 @@ func UnpackCommand() *cobra.Command { cmd.Flags().BoolVar(&opts.unpackConf.unpackDatasets, "datasets", false, "Unpack only datasets") cmd.Flags().BoolVar(&opts.unpackConf.unpackDocs, "docs", false, "Unpack only docs") opts.AddNetworkFlags(cmd) + cmd.Flags().SortFlags = false return cmd }