wslc: alias -f to --format on inspect commands for docker parity - #41463
Open
ggarzia-MSFT wants to merge 3 commits into
Open
wslc: alias -f to --format on inspect commands for docker parity#41463ggarzia-MSFT wants to merge 3 commits into
ggarzia-MSFT wants to merge 3 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
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
-falias toArgType::InspectFormatsoinspect -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 jsonmatches--format jsonoutput exactly and that invalid-fvalues 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>
ggarzia-MSFT
marked this pull request as ready for review
August 28, 2026 18:47
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
Adds docker's
-fshort alias for--formaton theinspectcommand family, sowslc inspect -f json <id>works the same waydocker inspect -fdoes.Docker defines this in
cli/command/system/inspect.go:wslcalready accepted--formaton all five inspect commands but registered it withNO_ALIAS, so the short form was rejected.PR Checklist
Detailed Description of the Pull Request / Additional comments
Single-line change in
ArgumentDefinitions.h:ArgType::InspectFormatgains thefalias.Because
InspectFormatis a distinctArgTypefrom the general-purposeFormat(used by the listcommands, where docker reserves
-ffor--filter), this picks up the alias only on the fivecommands that register it:
wslc inspectwslc container inspectwslc image inspectwslc network inspectwslc volume inspectNone of those commands register
--filter,--follow,--fileor--force, so there is noalias collision. The existing
AllCommands_NoAmbiguousArgumentNamesOrAliasesunit test walks thewhole 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 jsonis accepted and-f table/-f badformatare rejected with the existing error message.Localization
No new user-facing strings. The alias reuses the existing
WSLCCLI_InspectFormatArgDescriptiondescription, 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 everyinspect 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--formatwith aliasf.Value_AliasCarriesValue— drives the parser state machine to confirm the alias binds its valueto
ArgType::InspectFormatand does not swallow the following positional.E2E tests
WSLCE2E_Inspect_FormatAlias_MatchesLongName— asserts-f jsonand--format jsonproducebyte-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.