diff --git a/commands/root.go b/commands/root.go index 10263d11c2ab..519d89dd2b8d 100644 --- a/commands/root.go +++ b/commands/root.go @@ -79,7 +79,9 @@ func NewRootCmd(name string, isPlugin bool, dockerCli *command.DockerCli) *cobra cmd.SilenceErrors = true cmd.TraverseChildren = true cmd.DisableFlagsInUseLine = true - cli.DisableFlagsInUseLine(cmd) + visitAll(cmd, func(c *cobra.Command) { + c.DisableFlagsInUseLine = true + }) if !confutil.IsExperimental() { cmd.SetHelpTemplate(cmd.HelpTemplate() + "\n" + experimentalCommandHint + "\n") } @@ -99,6 +101,13 @@ func NewRootCmd(name string, isPlugin bool, dockerCli *command.DockerCli) *cobra return cmd } +func visitAll(root *cobra.Command, fn func(*cobra.Command)) { + for _, cmd := range root.Commands() { + visitAll(cmd, fn) + } + fn(root) +} + type rootOptions struct { builder string debug bool