mirror of https://github.com/docker/compose.git
Normalize case of command and flag help
Signed-off-by: Amos Law <ahlaw.dev@gmail.com>
This commit is contained in:
parent
e4fff081db
commit
e10424e316
|
@ -89,9 +89,9 @@ $ docker context create my-context --description "some description" --docker "ho
|
||||||
flags.String(
|
flags.String(
|
||||||
"default-stack-orchestrator", "",
|
"default-stack-orchestrator", "",
|
||||||
"Default orchestrator for stack operations to use with this context (swarm|kubernetes|all)")
|
"Default orchestrator for stack operations to use with this context (swarm|kubernetes|all)")
|
||||||
flags.StringToString("docker", nil, "set the docker endpoint")
|
flags.StringToString("docker", nil, "Set the docker endpoint")
|
||||||
flags.StringToString("kubernetes", nil, "set the kubernetes endpoint")
|
flags.StringToString("kubernetes", nil, "Set the kubernetes endpoint")
|
||||||
flags.String("from", "", "create context from a named context")
|
flags.String("from", "", "Create context from a named context")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ func removeCommand() *cobra.Command {
|
||||||
return runRemove(cmd.Context(), args, opts.force)
|
return runRemove(cmd.Context(), args, opts.force)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.Flags().BoolVarP(&opts.force, "force", "f", false, "force removing current context")
|
cmd.Flags().BoolVarP(&opts.force, "force", "f", false, "Force removing current context")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
13
cli/main.go
13
cli/main.go
|
@ -139,12 +139,16 @@ func main() {
|
||||||
helpFunc(cmd, args)
|
helpFunc(cmd, args)
|
||||||
})
|
})
|
||||||
|
|
||||||
root.PersistentFlags().BoolVarP(&opts.Debug, "debug", "D", false, "enable debug output in the logs")
|
root.PersistentFlags().BoolVarP(&opts.Debug, "debug", "D", false, "Enable debug output in the logs")
|
||||||
root.PersistentFlags().StringVarP(&opts.Host, "host", "H", "", "Daemon socket(s) to connect to")
|
root.PersistentFlags().StringVarP(&opts.Host, "host", "H", "", "Daemon socket(s) to connect to")
|
||||||
opts.AddConfigFlags(root.PersistentFlags())
|
opts.AddConfigFlags(root.PersistentFlags())
|
||||||
opts.AddContextFlags(root.PersistentFlags())
|
opts.AddContextFlags(root.PersistentFlags())
|
||||||
root.Flags().BoolVarP(&opts.Version, "version", "v", false, "Print version information and quit")
|
root.Flags().BoolVarP(&opts.Version, "version", "v", false, "Print version information and quit")
|
||||||
|
|
||||||
|
walk(root, func(c *cobra.Command) {
|
||||||
|
c.Flags().BoolP("help", "h", false, "Help for "+c.Name())
|
||||||
|
})
|
||||||
|
|
||||||
// populate the opts with the global flags
|
// populate the opts with the global flags
|
||||||
_ = root.PersistentFlags().Parse(os.Args[1:])
|
_ = root.PersistentFlags().Parse(os.Args[1:])
|
||||||
if opts.Debug {
|
if opts.Debug {
|
||||||
|
@ -277,3 +281,10 @@ func determineCurrentContext(flag string, configDir string) string {
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func walk(c *cobra.Command, f func(*cobra.Command)) {
|
||||||
|
f(c)
|
||||||
|
for _, c := range c.Commands() {
|
||||||
|
walk(c, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -50,9 +50,9 @@ Options:
|
||||||
this context
|
this context
|
||||||
(swarm|kubernetes|all)
|
(swarm|kubernetes|all)
|
||||||
--description string Description of the context
|
--description string Description of the context
|
||||||
--docker stringToString set the docker endpoint
|
--docker stringToString Set the docker endpoint
|
||||||
(default [])
|
(default [])
|
||||||
--kubernetes stringToString set the kubernetes endpoint
|
--kubernetes stringToString Set the kubernetes endpoint
|
||||||
(default [])
|
(default [])
|
||||||
--from string Create the context from an existing context
|
--from string Create the context from an existing context
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue