Skip to content

Commit 7203340

Browse files
committed
inspect: add shell-completion for "--type" flag
With this patch: docker inspect --type <TAB> config image node secret task container network plugin service volume Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 877ea1c commit 7203340

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

cli/command/system/inspect.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ const (
3939
typeVolume objectType = "volume"
4040
)
4141

42+
var allTypes = []objectType{
43+
typeConfig,
44+
typeContainer,
45+
typeImage,
46+
typeNetwork,
47+
typeNode,
48+
typePlugin,
49+
typeSecret,
50+
typeService,
51+
typeTask,
52+
typeVolume,
53+
}
54+
4255
type inspectOptions struct {
4356
format string
4457
objectType objectType
@@ -67,6 +80,7 @@ func NewInspectCommand(dockerCli command.Cli) *cobra.Command {
6780
flags.StringVar(&opts.objectType, "type", "", "Return JSON for specified type")
6881
flags.BoolVarP(&opts.size, "size", "s", false, "Display total file sizes if the type is container")
6982

83+
_ = cmd.RegisterFlagCompletionFunc("type", completion.FromList(allTypes...))
7084
flags.VisitAll(func(flag *pflag.Flag) {
7185
// Set a default completion function if none was set. We don't look
7286
// up if it does already have one set, because Cobra does this for

0 commit comments

Comments
 (0)