From 4c2fece0cb24acd84638e62a24b81f048350acd8 Mon Sep 17 00:00:00 2001 From: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> Date: Thu, 16 Jan 2025 11:20:52 +0100 Subject: [PATCH] cmd/docker: enable cobra completion descriptions This patch enables descriptions on the CLI completion script. It used to be disabled due to the CLI historically not supporting cobra v2 completions, as seen by this patch https://github.com/docker/cli/commit/cbec75e2f3f5afd3334db693829a6b150612076c. As an escape hatch, the user can set the `DOCKER_CLI_DISABLE_COMPLETION_DESCRIPTION` environment variable to disable the completion description when generating the completion file with `docker completion `. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> --- cli-plugins/plugin/plugin.go | 2 +- cmd/docker/docker.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli-plugins/plugin/plugin.go b/cli-plugins/plugin/plugin.go index 4ae85dbce4..cf57aad5e1 100644 --- a/cli-plugins/plugin/plugin.go +++ b/cli-plugins/plugin/plugin.go @@ -158,7 +158,7 @@ func newPluginCommand(dockerCli *command.DockerCli, plugin *cobra.Command, meta CompletionOptions: cobra.CompletionOptions{ DisableDefaultCmd: false, HiddenDefaultCmd: true, - DisableDescriptions: true, + DisableDescriptions: os.Getenv("DOCKER_CLI_DISABLE_COMPLETION_DESCRIPTION") != "", }, } opts, _ := cli.SetupPluginRootCommand(cmd) diff --git a/cmd/docker/docker.go b/cmd/docker/docker.go index 29a3ed5957..2f927aa1e6 100644 --- a/cmd/docker/docker.go +++ b/cmd/docker/docker.go @@ -92,7 +92,7 @@ func newDockerCommand(dockerCli *command.DockerCli) *cli.TopLevelCommand { CompletionOptions: cobra.CompletionOptions{ DisableDefaultCmd: false, HiddenDefaultCmd: true, - DisableDescriptions: true, + DisableDescriptions: os.Getenv("DOCKER_CLI_DISABLE_COMPLETION_DESCRIPTION") != "", }, } cmd.SetIn(dockerCli.In())