From 7203340f532588aecb42790c07309c9254ea12b0 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 6 May 2025 14:27:53 +0200 Subject: [PATCH] inspect: add shell-completion for "--type" flag With this patch: docker inspect --type config image node secret task container network plugin service volume Signed-off-by: Sebastiaan van Stijn --- cli/command/system/inspect.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cli/command/system/inspect.go b/cli/command/system/inspect.go index 7b0d84a55f..ea1cb0aca5 100644 --- a/cli/command/system/inspect.go +++ b/cli/command/system/inspect.go @@ -39,6 +39,19 @@ const ( typeVolume objectType = "volume" ) +var allTypes = []objectType{ + typeConfig, + typeContainer, + typeImage, + typeNetwork, + typeNode, + typePlugin, + typeSecret, + typeService, + typeTask, + typeVolume, +} + type inspectOptions struct { format string objectType objectType @@ -67,6 +80,7 @@ func NewInspectCommand(dockerCli command.Cli) *cobra.Command { flags.StringVar(&opts.objectType, "type", "", "Return JSON for specified type") flags.BoolVarP(&opts.size, "size", "s", false, "Display total file sizes if the type is container") + _ = cmd.RegisterFlagCompletionFunc("type", completion.FromList(allTypes...)) flags.VisitAll(func(flag *pflag.Flag) { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for