Skip to content

CLI: Add explicit per-command argument overrides - #41478

Open
David Bennett (dkbennett) wants to merge 7 commits into
masterfrom
user/dkbennett/aliasoverride
Open

CLI: Add explicit per-command argument overrides#41478
David Bennett (dkbennett) wants to merge 7 commits into
masterfrom
user/dkbennett/aliasoverride

Conversation

@dkbennett

@dkbennett David Bennett (dkbennett) commented Aug 29, 2026

Copy link
Copy Markdown
Member

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 calls Argument::Create:

Argument::Create(ArgType::ImageId, {.Required = true});
Argument::Create(ArgType::Filter, {.Alias = NO_ALIAS, .Limit = Limit::Unlimited});
Argument::Create(ArgType::Quiet, {.Name = L"silent", .Desc = Localization::...()});

The name, alias, and description in ArgumentDefinitions.h act 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 ArgType entries when commands expose the same logical argument with different names or aliases. For example, a command can remove Filter's default -f alias 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_NoAmbiguousArgumentNamesOrAliases evaluates each command's constructed arguments, so overridden names and aliases remain covered by collision detection.

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

Argument::Create now accepts an ArgumentOverrides aggregate with these optional fields:

  • .Name
  • .Alias
  • .Required
  • .Limit
  • .Desc

Omitted fields use the defaults associated with the selected ArgType. Passing .Alias = NO_ALIAS explicitly removes a default alias for one command.

Validation Steps Performed

  • Full x64 Debug build passes.
  • Unit coverage verifies default and overridden names and aliases, alias removal, parser behavior, and command-level collision detection.

Copilot AI lite review requested due to automatic review settings August 29, 2026 00:24
@dkbennett David Bennett (dkbennett) changed the title Enable Alias overrides for arguments CLI: Enable argument aliases to be overridden per-command Aug 29, 2026

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 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.h header 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.

Comment thread src/windows/wslc/arguments/Argument.h Outdated
Comment thread src/windows/wslc/arguments/Argument.cpp Outdated
Copilot AI review requested due to automatic review settings August 31, 2026 17:59

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 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 31, 2026 18:12

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 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslc/arguments/Argument.cpp Outdated
Copilot AI review requested due to automatic review settings August 31, 2026 18:41
@dkbennett David Bennett (dkbennett) changed the title CLI: Enable argument aliases to be overridden per-command CLI: Add explicit per-command argument overrides Aug 31, 2026

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 47 out of 47 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslc/arguments/Argument.h
Copilot AI review requested due to automatic review settings August 31, 2026 18:54
@dkbennett
David Bennett (dkbennett) marked this pull request as ready for review August 31, 2026 18:54

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 47 out of 47 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslc/arguments/Argument.h
Copilot AI review requested due to automatic review settings August 31, 2026 19:51

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 47 out of 47 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslc/arguments/Argument.h
Copilot AI review requested due to automatic review settings August 31, 2026 20:16

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 48 out of 48 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