Merge pull request #5223 from fredden/feature/completion/images

Enable completion for some 'image' sub commands
This commit is contained in:
Laura Brehm 2024-07-04 11:15:23 +01:00 committed by GitHub
commit f5ce584ce0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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/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",
},

View File

@ -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()

View File

@ -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",
},