From 15766209553523cb4ed1ce2f51389b043eb9abcb Mon Sep 17 00:00:00 2001 From: TastyHeadphones Date: Sat, 19 Sep 2026 01:28:31 +0000 Subject: [PATCH] inspect: list allowed object types in --type help The flag help only said "of the given type" without naming any. Include the same set we validate against so `docker inspect --help` is enough. --- cli/command/system/inspect.go | 2 +- cli/command/system/inspect_test.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cli/command/system/inspect.go b/cli/command/system/inspect.go index 1912400068ce..4617b15156c1 100644 --- a/cli/command/system/inspect.go +++ b/cli/command/system/inspect.go @@ -77,7 +77,7 @@ func newInspectCommand(dockerCLI command.Cli) *cobra.Command { flags := cmd.Flags() flags.StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp) - flags.StringVar(&opts.objectType, "type", "", "Only inspect objects of the given type") + flags.StringVar(&opts.objectType, "type", "", `Only inspect objects of the given type ("`+strings.Join(allTypes, `", "`)+`")`) flags.BoolVarP(&opts.size, "size", "s", false, "Display total file sizes if the type is container") _ = cmd.RegisterFlagCompletionFunc("type", completion.FromList(allTypes...)) diff --git a/cli/command/system/inspect_test.go b/cli/command/system/inspect_test.go index 3fbadc7f6d0f..0d5dfa0f314d 100644 --- a/cli/command/system/inspect_test.go +++ b/cli/command/system/inspect_test.go @@ -46,3 +46,13 @@ func TestInspectValidateFlagsAndArgs(t *testing.T) { }) } } + +func TestInspectTypeFlagHelpListsObjectTypes(t *testing.T) { + cmd := newInspectCommand(test.NewFakeCli(&fakeClient{})) + typeFlag := cmd.Flags().Lookup("type") + assert.Assert(t, typeFlag != nil) + usage := typeFlag.Usage + for _, objectType := range allTypes { + assert.Check(t, is.Contains(usage, objectType), "help should mention %q", objectType) + } +}