Skip to content

wslc: alias -f to --format on inspect commands for docker parity - #41463

Open
ggarzia-MSFT wants to merge 3 commits into
masterfrom
user/ggarzia/wslc-inspect-format-alias
Open

wslc: alias -f to --format on inspect commands for docker parity#41463
ggarzia-MSFT wants to merge 3 commits into
masterfrom
user/ggarzia/wslc-inspect-format-alias

Conversation

@ggarzia-MSFT

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Adds docker's -f short alias for --format on the inspect command family, so wslc inspect -f json <id> works the same way docker inspect -f does.

Docker defines this in cli/command/system/inspect.go:

flags.StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp)

wslc already accepted --format on all five inspect commands but registered it with NO_ALIAS, so the short form was rejected.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Single-line change in ArgumentDefinitions.h: ArgType::InspectFormat gains the f alias.

-_(InspectFormat,    "format",               NO_ALIAS,         Kind::Value,      JsonIndent,   ...)
+_(InspectFormat,    "format",               L"f",             Kind::Value,      JsonIndent,   ...)

Because InspectFormat is a distinct ArgType from the general-purpose Format (used by the list
commands, where docker reserves -f for --filter), this picks up the alias only on the five
commands that register it:

  • wslc inspect
  • wslc container inspect
  • wslc image inspect
  • wslc network inspect
  • wslc volume inspect

None of those commands register --filter, --follow, --file or --force, so there is no
alias collision. The existing AllCommands_NoAmbiguousArgumentNamesOrAliases unit test walks the
whole command tree and enforces this, and it still passes.

No behavior changes beyond accepting the short spelling — the alias flows through the same
validation and conversion path as the long name, so -f json is accepted and -f table /
-f badformat are rejected with the existing error message.

Localization

No new user-facing strings. The alias reuses the existing
WSLCCLI_InspectFormatArgDescription description, which already renders in help output.

Validation Steps Performed

Added tests only; no existing tests needed changing.

Parser cases (CommandLineTestCases.h) — 16 new table-driven cases covering the alias on every
inspect command, including the adjoined form (-f=json), the rejected values (-f table,
-f badformat) and the missing-value case (inspect -f).

Unit tests

  • InspectCommands_FormatArgumentHasDockerAlias — asserts all five inspect commands register
    --format with alias f.
  • Value_AliasCarriesValue — drives the parser state machine to confirm the alias binds its value
    to ArgType::InspectFormat and does not swallow the following positional.

E2E tests

  • WSLCE2E_Inspect_FormatAlias_MatchesLongName — asserts -f json and --format json produce
    byte-identical compact JSON.
  • WSLCE2E_Inspect_FormatAlias_InvalidValue — asserts the alias runs the same validation.
  • WSLCE2E_Image_Inspect_FormatAlias_MatchesLongName — same equivalence check on a subcommand.

Build is clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 27, 2026 18:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds Docker-parity support for -f as a short alias of --format across the wslc inspect command family (root inspect plus container/image/network/volume inspect), by updating the ArgType::InspectFormat definition and adding unit/E2E coverage to lock the behavior in.

Changes:

  • Add -f alias to ArgType::InspectFormat so inspect -f json ... is accepted (including -f=json).
  • Add parser + command-tree unit tests to ensure the alias binds values correctly and is registered on all inspect commands.
  • Add E2E tests verifying -f json matches --format json output exactly and that invalid -f values follow the same validation path.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/windows/wslc/arguments/ArgumentDefinitions.h Adds L"f" alias to InspectFormat argument definition.
test/windows/wslc/WSLCCLIParserUnitTests.cpp Adds unit test validating value-argument aliases carry values (including -f=json) without consuming positionals.
test/windows/wslc/WSLCCLICommandUnitTests.cpp Adds unit test asserting all inspect-family commands expose --format with alias -f.
test/windows/wslc/CommandLineTestCases.h Adds table-driven parser cases for -f across inspect commands, including invalid and missing-value cases.
test/windows/wslc/e2e/WSLCE2EInspectTests.cpp Adds E2E coverage for inspect -f output equivalence and invalid-value handling.
test/windows/wslc/e2e/WSLCE2EImageInspectTests.cpp Adds E2E equivalence coverage for image inspect -f vs --format.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 28, 2026 00:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread test/windows/wslc/WSLCCLIParserUnitTests.cpp Outdated
@ggarzia-MSFT
ggarzia-MSFT marked this pull request as ready for review August 28, 2026 18:47
@ggarzia-MSFT
ggarzia-MSFT requested review from a team as code owners August 28, 2026 18:47
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 28, 2026 18:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants