Skip to content

Commit 0adaf6b

Browse files
committed
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 <[email protected]>
1 parent ba21666 commit 0adaf6b

File tree

155 files changed

+434
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+434
-257
lines changed

cli/command/builder/cmd.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func newBuilderCommand(dockerCLI command.Cli) *cobra.Command {
2424
Args: cli.NoArgs,
2525
RunE: command.ShowHelp(dockerCLI.Err()),
2626
Annotations: map[string]string{"version": "1.31"},
27+
28+
DisableFlagsInUseLine: true,
2729
}
2830
cmd.AddCommand(
2931
newPruneCommand(dockerCLI),
@@ -50,5 +52,6 @@ func newBakeStubCommand(dockerCLI command.Streams) *cobra.Command {
5052
"aliases": "docker buildx bake",
5153
"version": "1.31",
5254
},
55+
DisableFlagsInUseLine: true,
5356
}
5457
}

cli/command/builder/prune.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
5050
_, _ = fmt.Fprintln(dockerCLI.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
5151
return nil
5252
},
53-
Annotations: map[string]string{"version": "1.39"},
54-
ValidArgsFunction: cobra.NoFileCompletions,
53+
Annotations: map[string]string{"version": "1.39"},
54+
ValidArgsFunction: cobra.NoFileCompletions,
55+
DisableFlagsInUseLine: true,
5556
}
5657

5758
flags := cmd.Flags()

cli/command/checkpoint/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func newCheckpointCommand(dockerCLI command.Cli) *cobra.Command {
2323
"ostype": "linux",
2424
"version": "1.25",
2525
},
26+
DisableFlagsInUseLine: true,
2627
}
2728
cmd.AddCommand(
2829
newCreateCommand(dockerCLI),

cli/command/checkpoint/create.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type createOptions struct {
1717
leaveRunning bool
1818
}
1919

20-
func newCreateCommand(dockerCli command.Cli) *cobra.Command {
20+
func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
2121
var opts createOptions
2222

2323
cmd := &cobra.Command{
@@ -27,9 +27,10 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
2727
RunE: func(cmd *cobra.Command, args []string) error {
2828
opts.container = args[0]
2929
opts.checkpoint = args[1]
30-
return runCreate(cmd.Context(), dockerCli, opts)
30+
return runCreate(cmd.Context(), dockerCLI, opts)
3131
},
32-
ValidArgsFunction: cobra.NoFileCompletions,
32+
ValidArgsFunction: cobra.NoFileCompletions,
33+
DisableFlagsInUseLine: true,
3334
}
3435

3536
flags := cmd.Flags()

cli/command/checkpoint/list.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type listOptions struct {
1515
checkpointDir string
1616
}
1717

18-
func newListCommand(dockerCli command.Cli) *cobra.Command {
18+
func newListCommand(dockerCLI command.Cli) *cobra.Command {
1919
var opts listOptions
2020

2121
cmd := &cobra.Command{
@@ -24,9 +24,10 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
2424
Short: "List checkpoints for a container",
2525
Args: cli.ExactArgs(1),
2626
RunE: func(cmd *cobra.Command, args []string) error {
27-
return runList(cmd.Context(), dockerCli, args[0], opts)
27+
return runList(cmd.Context(), dockerCLI, args[0], opts)
2828
},
29-
ValidArgsFunction: completion.ContainerNames(dockerCli, false),
29+
ValidArgsFunction: completion.ContainerNames(dockerCLI, false),
30+
DisableFlagsInUseLine: true,
3031
}
3132

3233
flags := cmd.Flags()

cli/command/checkpoint/remove.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type removeOptions struct {
1313
checkpointDir string
1414
}
1515

16-
func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
16+
func newRemoveCommand(dockerCLI command.Cli) *cobra.Command {
1717
var opts removeOptions
1818

1919
cmd := &cobra.Command{
@@ -22,8 +22,9 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
2222
Short: "Remove a checkpoint",
2323
Args: cli.ExactArgs(2),
2424
RunE: func(cmd *cobra.Command, args []string) error {
25-
return runRemove(cmd.Context(), dockerCli, args[0], args[1], opts)
25+
return runRemove(cmd.Context(), dockerCLI, args[0], args[1], opts)
2626
},
27+
DisableFlagsInUseLine: true,
2728
}
2829

2930
flags := cmd.Flags()

cli/command/config/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func newConfigCommand(dockerCLI command.Cli) *cobra.Command {
2424
"version": "1.30",
2525
"swarm": "manager",
2626
},
27+
DisableFlagsInUseLine: true,
2728
}
2829
cmd.AddCommand(
2930
newConfigListCommand(dockerCLI),

cli/command/config/create.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ func newConfigCreateCommand(dockerCLI command.Cli) *cobra.Command {
3636
createOpts.file = args[1]
3737
return runCreate(cmd.Context(), dockerCLI, createOpts)
3838
},
39-
ValidArgsFunction: cobra.NoFileCompletions,
39+
ValidArgsFunction: cobra.NoFileCompletions,
40+
DisableFlagsInUseLine: true,
4041
}
4142
flags := cmd.Flags()
4243
flags.VarP(&createOpts.labels, "label", "l", "Config labels")

cli/command/config/inspect.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func newConfigInspectCommand(dockerCLI command.Cli) *cobra.Command {
3535
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
3636
return completeNames(dockerCLI)(cmd, args, toComplete)
3737
},
38+
DisableFlagsInUseLine: true,
3839
}
3940

4041
cmd.Flags().StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp)

cli/command/config/ls.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ func newConfigListCommand(dockerCLI command.Cli) *cobra.Command {
3232
RunE: func(cmd *cobra.Command, args []string) error {
3333
return runList(cmd.Context(), dockerCLI, listOpts)
3434
},
35-
ValidArgsFunction: cobra.NoFileCompletions,
35+
ValidArgsFunction: cobra.NoFileCompletions,
36+
DisableFlagsInUseLine: true,
3637
}
3738

3839
flags := cmd.Flags()

0 commit comments

Comments
 (0)