mirror of https://github.com/docker/cli.git
Don't automagically add "[OPTIONS]" to usage
This removes the logic to automatically add [OPTIONS] to the usage output. The current logic was broken if a command only has deprecated or hidden flags, and in many cases put the [OPTIONS] in the wrong location. Requiring the usage string to be set manually gives more predictable results, and shouldn't require much to maintain. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
5545165e02
commit
6393b5fcc7
7
cli.go
7
cli.go
|
@ -155,11 +155,6 @@ func Subcmd(name string, synopses []string, description string, exitOnError bool
|
|||
}
|
||||
|
||||
flags.ShortUsage = func() {
|
||||
options := ""
|
||||
if flags.FlagCountUndeprecated() > 0 {
|
||||
options = " [OPTIONS]"
|
||||
}
|
||||
|
||||
if len(synopses) == 0 {
|
||||
synopses = []string{""}
|
||||
}
|
||||
|
@ -176,7 +171,7 @@ func Subcmd(name string, synopses []string, description string, exitOnError bool
|
|||
synopsis = " " + synopsis
|
||||
}
|
||||
|
||||
fmt.Fprintf(flags.Out(), "\n%sdocker %s%s%s", lead, name, options, synopsis)
|
||||
fmt.Fprintf(flags.Out(), "\n%sdocker %s%s", lead, name, synopsis)
|
||||
}
|
||||
|
||||
fmt.Fprintf(flags.Out(), "\n\n%s\n", description)
|
||||
|
|
|
@ -32,7 +32,7 @@ func NewCobraAdaptor(clientFlags *cliflags.ClientFlags) CobraAdaptor {
|
|||
dockerCli := client.NewDockerCli(stdin, stdout, stderr, clientFlags)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "docker",
|
||||
Use: "docker [OPTIONS]",
|
||||
SilenceUsage: true,
|
||||
SilenceErrors: true,
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func (c CobraAdaptor) Command(name string) func(...string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
var usageTemplate = `Usage: {{if not .HasSubCommands}}{{if .HasLocalFlags}}{{appendIfNotPresent .UseLine "[OPTIONS]"}}{{else}}{{.UseLine}}{{end}}{{end}}{{if .HasSubCommands}}{{ .CommandPath}} COMMAND{{end}}
|
||||
var usageTemplate = `Usage: {{if not .HasSubCommands}}{{.UseLine}}{{end}}{{if .HasSubCommands}}{{ .CommandPath}} COMMAND{{end}}
|
||||
|
||||
{{with or .Long .Short }}{{. | trim}}{{end}}{{if gt .Aliases 0}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue