Skip to content

Commit 47b1715

Browse files
committed
cli-plugins: disable file-completion by default
This uses the DefaultShellCompDirective feature which was added in cobra to override the default (which would complete to use files for commands and flags). Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 78c5464 commit 47b1715

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cli-plugins/plugin/plugin.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ func newPluginCommand(dockerCli *command.DockerCli, plugin *cobra.Command, meta
164164
DisableDescriptions: os.Getenv("DOCKER_CLI_DISABLE_COMPLETION_DESCRIPTION") != "",
165165
},
166166
}
167+
168+
// Disable file-completion by default. Most commands and flags should not
169+
// complete with filenames.
170+
cmd.CompletionOptions.SetDefaultShellCompDirective(cobra.ShellCompDirectiveNoFileComp)
171+
167172
opts, _ := cli.SetupPluginRootCommand(cmd)
168173

169174
cmd.SetIn(dockerCli.In())

0 commit comments

Comments
 (0)