verify that DisableFlagsInUseLine is set for all commands

This replaces the visitAll recursive function with a test that verifies that
the option is set for all commands and subcommands, so that it doesn't have
to be modified at runtime.

We currently still have to loop over all functions for the setValidateArgs
call, but that can be looked at separately.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-08-29 22:40:57 +02:00
parent ba21666654
commit 0adaf6be3b
155 changed files with 434 additions and 257 deletions

View File

@ -11,7 +11,7 @@ import (
"github.com/spf13/cobra"
)
func newEnableCommand(dockerCli command.Cli) *cobra.Command {
func newEnableCommand(dockerCLI command.Cli) *cobra.Command {
var opts client.PluginEnableOptions
cmd := &cobra.Command{
@ -20,12 +20,13 @@ func newEnableCommand(dockerCli command.Cli) *cobra.Command {
Args: cli.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
name := args[0]
if err := runEnable(cmd.Context(), dockerCli, name, opts); err != nil {
if err := runEnable(cmd.Context(), dockerCLI, name, opts); err != nil {
return err
}
_, _ = fmt.Fprintln(dockerCli.Out(), name)
_, _ = fmt.Fprintln(dockerCLI.Out(), name)
return nil
},
DisableFlagsInUseLine: true,
}
flags := cmd.Flags()