cli/command/completion: deprecate NoComplete · docker/cli@2827d03 (original) (raw)

Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import (
8 8
9 9 "github.com/docker/cli/cli"
10 10 "github.com/docker/cli/cli/command"
11 -"github.com/docker/cli/cli/command/completion"
12 11 "github.com/docker/cli/cli/command/system/pruner"
13 12 "github.com/docker/cli/internal/prompt"
14 13 "github.com/docker/cli/opts"
@@ -52,7 +51,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
52 51 return nil
53 52 },
54 53 Annotations: map[string]string{"version": "1.39"},
55 -ValidArgsFunction: completion.NoComplete,
54 +ValidArgsFunction: cobra.NoFileCompletions,
56 55 }
57 56
58 57 flags := cmd.Flags()
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ import (
6 6
7 7 "github.com/docker/cli/cli"
8 8 "github.com/docker/cli/cli/command"
9 -"github.com/docker/cli/cli/command/completion"
10 9 "github.com/moby/moby/api/types/checkpoint"
11 10 "github.com/spf13/cobra"
12 11 )
@@ -30,7 +29,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
30 29 opts.checkpoint = args[1]
31 30 return runCreate(cmd.Context(), dockerCli, opts)
32 31 },
33 -ValidArgsFunction: completion.NoComplete,
32 +ValidArgsFunction: cobra.NoFileCompletions,
34 33 }
35 34
36 35 flags := cmd.Flags()
Original file line number Diff line number Diff line change
@@ -138,7 +138,9 @@ func FileNames(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCom
138 138 return nil, cobra.ShellCompDirectiveDefault
139 139 }
140 140
141 -// NoComplete is used for commands where there's no relevant completion
141 +// NoComplete is used for commands where there's no relevant completion.
142 +//
143 +// Deprecated: use [cobra.NoFileCompletions]. This function will be removed in the next release.
142 144 func NoComplete(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
143 145 return nil, cobra.ShellCompDirectiveNoFileComp
144 146 }
Original file line number Diff line number Diff line change
@@ -288,12 +288,6 @@ func TestCompleteNetworkNames(t *testing.T) {
288 288 }
289 289 }
290 290
291 -func TestCompleteNoComplete(t *testing.T) {
292 -values, directives := NoComplete(nil, nil, "")
293 -assert.Check(t, is.Equal(directives, cobra.ShellCompDirectiveNoFileComp))
294 -assert.Check(t, is.Len(values, 0))
295 -}
296 -
297 291 func TestCompletePlatforms(t *testing.T) {
298 292 values, directives := Platforms(nil, nil, "")
299 293 assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp), "Should not perform file completion")
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import (
8 8
9 9 "github.com/docker/cli/cli"
10 10 "github.com/docker/cli/cli/command"
11 -"github.com/docker/cli/cli/command/completion"
12 11 "github.com/docker/cli/opts"
13 12 "github.com/moby/moby/api/types/swarm"
14 13 "github.com/moby/sys/sequential"
@@ -37,7 +36,7 @@ func newConfigCreateCommand(dockerCLI command.Cli) *cobra.Command {
37 36 createOpts.file = args[1]
38 37 return runCreate(cmd.Context(), dockerCLI, createOpts)
39 38 },
40 -ValidArgsFunction: completion.NoComplete,
39 +ValidArgsFunction: cobra.NoFileCompletions,
41 40 }
42 41 flags := cmd.Flags()
43 42 flags.VarP(&createOpts.labels, "label", "l", "Config labels")
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ import (
6 6
7 7 "github.com/docker/cli/cli"
8 8 "github.com/docker/cli/cli/command"
9 -"github.com/docker/cli/cli/command/completion"
10 9 "github.com/docker/cli/cli/command/formatter"
11 10 flagsHelper "github.com/docker/cli/cli/flags"
12 11 "github.com/docker/cli/opts"
@@ -33,7 +32,7 @@ func newConfigListCommand(dockerCLI command.Cli) *cobra.Command {
33 32 RunE: func(cmd *cobra.Command, args []string) error {
34 33 return runList(cmd.Context(), dockerCLI, listOpts)
35 34 },
36 -ValidArgsFunction: completion.NoComplete,
35 +ValidArgsFunction: cobra.NoFileCompletions,
37 36 }
38 37
39 38 flags := cmd.Flags()
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
98 98 // Set a default completion function if none was set. We don't look
99 99 // up if it does already have one set, because Cobra does this for
100 100 // us, and returns an error (which we ignore for this reason).
101 -_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
101 +_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
102 102 })
103 103
104 104 return cmd
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ import (
6 6
7 7 "github.com/docker/cli/cli"
8 8 "github.com/docker/cli/cli/command"
9 -"github.com/docker/cli/cli/command/completion"
10 9 "github.com/docker/cli/cli/command/formatter"
11 10 flagsHelper "github.com/docker/cli/cli/flags"
12 11 "github.com/docker/cli/opts"
@@ -44,7 +43,7 @@ func newPsCommand(dockerCLI command.Cli) *cobra.Command {
44 43 "category-top": "3",
45 44 "aliases": "docker container ls, docker container list, docker container ps, docker ps",
46 45 },
47 -ValidArgsFunction: completion.NoComplete,
46 +ValidArgsFunction: cobra.NoFileCompletions,
48 47 }
49 48
50 49 flags := cmd.Flags()
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ import (
6 6
7 7 "github.com/docker/cli/cli"
8 8 "github.com/docker/cli/cli/command"
9 -"github.com/docker/cli/cli/command/completion"
10 9 "github.com/docker/cli/cli/command/system/pruner"
11 10 "github.com/docker/cli/internal/prompt"
12 11 "github.com/docker/cli/opts"
@@ -47,7 +46,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
47 46 return nil
48 47 },
49 48 Annotations: map[string]string{"version": "1.25"},
50 -ValidArgsFunction: completion.NoComplete,
49 +ValidArgsFunction: cobra.NoFileCompletions,
51 50 }
52 51
53 52 flags := cmd.Flags()
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ func newRunCommand(dockerCLI command.Cli) *cobra.Command {
78 78 // Set a default completion function if none was set. We don't look
79 79 // up if it does already have one set, because Cobra does this for
80 80 // us, and returns an error (which we ignore for this reason).
81 -_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
81 +_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
82 82 })
83 83
84 84 return cmd