CLI: Add explicit per-command argument overrides - #41478
Open
David Bennett (dkbennett) wants to merge 7 commits into
Open
CLI: Add explicit per-command argument overrides#41478David Bennett (dkbennett) wants to merge 7 commits into
David Bennett (dkbennett) wants to merge 7 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the WSLC CLI argument model to support per-command alias overrides by adding an Argument::Create overload that accepts an alias override (including removing aliases), while keeping the existing creation API stable. This enables commands to reuse an existing ArgType definition and only customize its short-form alias where needed.
Changes:
- Added
Argument::Create(ArgType, std::wstring alias, ...)and refactored creation to share a single internal helper. - Updated
ArgumentDefinitions.hheader comments to describe aliases as defaults that commands can override. - Added unit tests covering alias defaulting, explicit alias override, and alias removal behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/wslc/WSLCCLIParserUnitTests.cpp | Adds a parser-level test verifying command-provided alias overrides control which short flag is accepted. |
| test/windows/wslc/WSLCCLIArgumentUnitTests.cpp | Adds unit tests validating default alias behavior, explicit alias removal, and custom alias + other overrides in Argument::Create. |
| src/windows/wslc/arguments/ArgumentDefinitions.h | Updates documentation to clarify aliases/descriptions are defaults and can be overridden by commands. |
| src/windows/wslc/arguments/Argument.h | Adds the new Argument::Create overload and changes NO_ALIAS definition. |
| src/windows/wslc/arguments/Argument.cpp | Implements the overload via a shared internal CreateArgument helper and applies alias override/defaulting logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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 explicit command-level argument overrides through
ArgumentOverrides. The name, alias, required state, limit, and description defined for an argument can now be overridden when a command callsArgument::Create:The name, alias, and description in
ArgumentDefinitions.hact as defaults.ArgType,Kind, and conversion type remain fixed because they define the argument's identity, parsing behavior, and stored value type.This avoids creating duplicate
ArgTypeentries when commands expose the same logical argument with different names or aliases. For example, a command can remove Filter's default-falias without introducing a separate argument type and duplicating its validation behavior.Existing command declarations that override required state, limit, or description now use designated fields instead of positional parameters. This makes each command's deviations from the shared defaults visible directly in its argument list.
AllCommands_NoAmbiguousArgumentNamesOrAliasesevaluates each command's constructed arguments, so overridden names and aliases remain covered by collision detection.PR Checklist
Detailed Description of the Pull Request / Additional comments
Argument::Createnow accepts anArgumentOverridesaggregate with these optional fields:.Name.Alias.Required.Limit.DescOmitted fields use the defaults associated with the selected
ArgType. Passing.Alias = NO_ALIASexplicitly removes a default alias for one command.Validation Steps Performed