move commonly used top-level commands to the top of --help

This adds a new annotation to commands that are known to be frequently
used, and allows setting a custom weight/order for these commands to
influence in what order they appear in the --help output.

I'm not entirely happy with the implementation (we could at least use
some helpers for this, and/or make it more generic to group commands
in output), but it could be a start.

For now, limiting this to only be used for the top-level --help, but
we can expand this to subcommands as well if we think it makes sense
to highlight "common" / "commonly used" commands.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2022-03-30 09:37:08 +02:00
parent a058f9774a
commit aaa912c9f7
13 changed files with 78 additions and 0 deletions

View File

@ -44,6 +44,9 @@ func NewLoginCommand(dockerCli command.Cli) *cobra.Command {
}
return runLogin(dockerCli, opts)
},
Annotations: map[string]string{
"category-top": "8",
},
}
flags := cmd.Flags()

View File

@ -23,6 +23,9 @@ func NewLogoutCommand(dockerCli command.Cli) *cobra.Command {
}
return runLogout(dockerCli, serverAddress)
},
Annotations: map[string]string{
"category-top": "9",
},
}
return cmd

View File

@ -32,6 +32,9 @@ func NewSearchCommand(dockerCli command.Cli) *cobra.Command {
options.term = args[0]
return runSearch(dockerCli, options)
},
Annotations: map[string]string{
"category-top": "10",
},
}
flags := cmd.Flags()