From 5f7c43e5e66d7026cb27703b08720aeee6a9da5e Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Thu, 24 Oct 2024 20:14:49 +0000 Subject: [PATCH] Add completion for `--detach-keys` Signed-off-by: Harald Albers --- cli/command/container/completion.go | 5 +++++ cli/command/container/run.go | 1 + 2 files changed, 6 insertions(+) diff --git a/cli/command/container/completion.go b/cli/command/container/completion.go index f988d2c0c1..23a1dedfd7 100644 --- a/cli/command/container/completion.go +++ b/cli/command/container/completion.go @@ -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) { diff --git a/cli/command/container/run.go b/cli/command/container/run.go index ad8afcab82..1077a9994a 100644 --- a/cli/command/container/run.go +++ b/cli/command/container/run.go @@ -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