Enable completion for 'image' sub commands

Signed-off-by: Dan Wallis <dan@wallis.nz>
This commit is contained in:
Dan Wallis 2024-07-03 16:42:29 +01:00
parent bab48ebcc8
commit c7d46aa7a1
No known key found for this signature in database
GPG Key ID: A02198884F2740BC
3 changed files with 6 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"github.com/docker/cli/cli" "github.com/docker/cli/cli"
"github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
"github.com/docker/cli/cli/command/formatter" "github.com/docker/cli/cli/command/formatter"
flagsHelper "github.com/docker/cli/cli/flags" flagsHelper "github.com/docker/cli/cli/flags"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -31,6 +32,7 @@ func NewHistoryCommand(dockerCli command.Cli) *cobra.Command {
opts.image = args[0] opts.image = args[0]
return runHistory(cmd.Context(), dockerCli, opts) return runHistory(cmd.Context(), dockerCli, opts)
}, },
ValidArgsFunction: completion.ImageNames(dockerCli),
Annotations: map[string]string{ Annotations: map[string]string{
"aliases": "docker image history, docker history", "aliases": "docker image history, docker history",
}, },

View File

@ -8,6 +8,7 @@ import (
"github.com/docker/cli/cli" "github.com/docker/cli/cli"
"github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
"github.com/docker/cli/cli/command/inspect" "github.com/docker/cli/cli/command/inspect"
flagsHelper "github.com/docker/cli/cli/flags" flagsHelper "github.com/docker/cli/cli/flags"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -30,6 +31,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command {
opts.refs = args opts.refs = args
return runInspect(cmd.Context(), dockerCli, opts) return runInspect(cmd.Context(), dockerCli, opts)
}, },
ValidArgsFunction: completion.ImageNames(dockerCli),
} }
flags := cmd.Flags() flags := cmd.Flags()

View File

@ -7,6 +7,7 @@ import (
"github.com/docker/cli/cli" "github.com/docker/cli/cli"
"github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -29,6 +30,7 @@ func NewRemoveCommand(dockerCli command.Cli) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return runRemove(cmd.Context(), dockerCli, opts, args) return runRemove(cmd.Context(), dockerCli, opts, args)
}, },
ValidArgsFunction: completion.ImageNames(dockerCli),
Annotations: map[string]string{ Annotations: map[string]string{
"aliases": "docker image rm, docker image remove, docker rmi", "aliases": "docker image rm, docker image remove, docker rmi",
}, },