Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we would not be doing this at runtime, but perhaps instead a test that validates all commands have the option set (I was considering this for the CLI itself as well).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

})
if !confutil.IsExperimental() {
cmd.SetHelpTemplate(cmd.HelpTemplate() + "\n" + experimentalCommandHint + "\n")
}
Expand All @@ -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
Expand Down