@@ -116,14 +116,16 @@ func NetworkNames(dockerCLI APIClientProvider) cobra.CompletionFunc {
116116// export MY_VAR=hello
117117// docker run --rm --env MY_VAR alpine printenv MY_VAR
118118// hello
119- func EnvVarNames (_ * cobra.Command , _ []string , _ string ) (names []string , _ cobra.ShellCompDirective ) {
120- envs := os .Environ ()
121- names = make ([]string , 0 , len (envs ))
122- for _ , env := range envs {
123- name , _ , _ := strings .Cut (env , "=" )
124- names = append (names , name )
119+ func EnvVarNames () cobra.CompletionFunc {
120+ return func (_ * cobra.Command , _ []string , _ string ) (names []string , _ cobra.ShellCompDirective ) {
121+ envs := os .Environ ()
122+ names = make ([]string , 0 , len (envs ))
123+ for _ , env := range envs {
124+ name , _ , _ := strings .Cut (env , "=" )
125+ names = append (names , name )
126+ }
127+ return names , cobra .ShellCompDirectiveNoFileComp
125128 }
126- return names , cobra .ShellCompDirectiveNoFileComp
127129}
128130
129131// FromList offers completion for the given list of options.
@@ -134,8 +136,10 @@ func FromList(options ...string) cobra.CompletionFunc {
134136// FileNames is a convenience function to use [cobra.ShellCompDirectiveDefault],
135137// which indicates to let the shell perform its default behavior after
136138// completions have been provided.
137- func FileNames (_ * cobra.Command , _ []string , _ string ) ([]string , cobra.ShellCompDirective ) {
138- return nil , cobra .ShellCompDirectiveDefault
139+ func FileNames () cobra.CompletionFunc {
140+ return func (_ * cobra.Command , _ []string , _ string ) ([]string , cobra.ShellCompDirective ) {
141+ return nil , cobra .ShellCompDirectiveDefault
142+ }
139143}
140144
141145var commonPlatforms = []string {
@@ -175,6 +179,8 @@ var commonPlatforms = []string{
175179// - we currently exclude architectures that may have unofficial builds,
176180// but don't have wide adoption (and no support), such as loong64, mipsXXX,
177181// ppc64 (non-le) to prevent confusion.
178- func Platforms (_ * cobra.Command , _ []string , _ string ) (platforms []string , _ cobra.ShellCompDirective ) {
179- return commonPlatforms , cobra .ShellCompDirectiveNoFileComp
182+ func Platforms () cobra.CompletionFunc {
183+ return func (_ * cobra.Command , _ []string , _ string ) ([]string , cobra.ShellCompDirective ) {
184+ return commonPlatforms , cobra .ShellCompDirectiveNoFileComp
185+ }
180186}
0 commit comments