Hide [flags] in usage output
This patch hides the [flags] in the usage output of commands, using the new `.DisableFlagsInUseLine` option, instead of the temporary workaround added in8e600e10f7Before this change: docker run "docker run" requires at least 1 argument. See 'docker run --help'. Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] [flags] Run a command in a new container After this change: docker run "docker run" requires at least 1 argument. See 'docker run --help'. Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Run a command in a new container Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit:00d080269aComponent: cli
This commit is contained in:
@@ -41,7 +41,8 @@ func newDockerCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||
}
|
||||
return isSupported(cmd, dockerCli)
|
||||
},
|
||||
Version: fmt.Sprintf("%s, build %s", cli.Version, cli.GitCommit),
|
||||
Version: fmt.Sprintf("%s, build %s", cli.Version, cli.GitCommit),
|
||||
DisableFlagsInUseLine: true,
|
||||
}
|
||||
cli.SetupRootCommand(cmd)
|
||||
|
||||
@@ -57,11 +58,19 @@ func newDockerCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||
cmd.SetOutput(dockerCli.Out())
|
||||
commands.AddCommands(cmd, dockerCli)
|
||||
|
||||
disableFlagsInUseLine(cmd)
|
||||
setValidateArgs(dockerCli, cmd, flags, opts)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func disableFlagsInUseLine(cmd *cobra.Command) {
|
||||
visitAll(cmd, func(ccmd *cobra.Command) {
|
||||
// do not add a `[flags]` to the end of the usage line.
|
||||
ccmd.DisableFlagsInUseLine = true
|
||||
})
|
||||
}
|
||||
|
||||
func setFlagErrorFunc(dockerCli *command.DockerCli, cmd *cobra.Command, flags *pflag.FlagSet, opts *cliflags.ClientOptions) {
|
||||
// When invoking `docker stack --nonsense`, we need to make sure FlagErrorFunc return appropriate
|
||||
// output if the feature is not supported.
|
||||
|
||||
Reference in New Issue
Block a user