Add completion for `--detach-keys`

Signed-off-by: Harald Albers <github@albersweb.de>
(cherry picked from commit 5f7c43e5e6)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Harald Albers 2024-10-24 20:14:49 +00:00 committed by Sebastiaan van Stijn
parent e25548d1c6
commit 83303411ee
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 6 additions and 0 deletions

View File

@ -75,6 +75,11 @@ func addCompletions(cmd *cobra.Command, dockerCLI completion.APIClientProvider)
_ = cmd.RegisterFlagCompletionFunc("volumes-from", completion.ContainerNames(dockerCLI, true))
}
// completeDetachKeys implements shell completion for the `--detach-keys` option of `run` and `create`.
func completeDetachKeys(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return []string{"ctrl-"}, cobra.ShellCompDirectiveNoSpace
}
// completeIpc implements shell completion for the `--ipc` option of `run` and `create`.
// The completion is partly composite.
func completeIpc(dockerCLI completion.APIClientProvider) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {

View File

@ -69,6 +69,7 @@ func NewRunCommand(dockerCli command.Cli) *cobra.Command {
command.AddTrustVerificationFlags(flags, &options.untrusted, dockerCli.ContentTrustEnabled())
copts = addFlags(flags)
_ = cmd.RegisterFlagCompletionFunc("detach-keys", completeDetachKeys)
addCompletions(cmd, dockerCli)
return cmd