From c7d46aa7a1b71b9e8a6920812de72c5b680a3f7c Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Wed, 3 Jul 2024 16:42:29 +0100 Subject: [PATCH] Enable completion for 'image' sub commands Signed-off-by: Dan Wallis --- cli/command/image/history.go | 2 ++ cli/command/image/inspect.go | 2 ++ cli/command/image/remove.go | 2 ++ 3 files changed, 6 insertions(+) diff --git a/cli/command/image/history.go b/cli/command/image/history.go index e36b9bc03c..1c0ae40981 100644 --- a/cli/command/image/history.go +++ b/cli/command/image/history.go @@ -5,6 +5,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" + "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" flagsHelper "github.com/docker/cli/cli/flags" "github.com/spf13/cobra" @@ -31,6 +32,7 @@ func NewHistoryCommand(dockerCli command.Cli) *cobra.Command { opts.image = args[0] return runHistory(cmd.Context(), dockerCli, opts) }, + ValidArgsFunction: completion.ImageNames(dockerCli), Annotations: map[string]string{ "aliases": "docker image history, docker history", }, diff --git a/cli/command/image/inspect.go b/cli/command/image/inspect.go index 96b3bb8f4c..90fc670400 100644 --- a/cli/command/image/inspect.go +++ b/cli/command/image/inspect.go @@ -8,6 +8,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" + "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/inspect" flagsHelper "github.com/docker/cli/cli/flags" "github.com/spf13/cobra" @@ -30,6 +31,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command { opts.refs = args return runInspect(cmd.Context(), dockerCli, opts) }, + ValidArgsFunction: completion.ImageNames(dockerCli), } flags := cmd.Flags() diff --git a/cli/command/image/remove.go b/cli/command/image/remove.go index e0983f377f..3fb0af5c03 100644 --- a/cli/command/image/remove.go +++ b/cli/command/image/remove.go @@ -7,6 +7,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" + "github.com/docker/cli/cli/command/completion" "github.com/docker/docker/api/types/image" "github.com/docker/docker/errdefs" "github.com/pkg/errors" @@ -29,6 +30,7 @@ func NewRemoveCommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runRemove(cmd.Context(), dockerCli, opts, args) }, + ValidArgsFunction: completion.ImageNames(dockerCli), Annotations: map[string]string{ "aliases": "docker image rm, docker image remove, docker rmi", },