Skip to content

chore: Allow multiple CLI option parameter with same key - #3277

Open
filzrev wants to merge 4 commits into
dotnet:masterfrom
filzrev:chore-allow-multiple-same-cli-parameters
Open

filzrev wants to merge 4 commits into
dotnet:masterfrom
filzrev:chore-allow-multiple-same-cli-parameters

Conversation

@filzrev

@filzrev filzrev commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

This PR contains following changes.

What's changed in this PR.

1. Enable CommandLineParser's AllowMultiInstance option
This option is introduced at CommandLineParser v2.9.1.
By enable this option, it can specify same options multiple times (e.g. --filter A --filter B instead of --filter A B)

2. Modify CommandLineOptions.cs and add additional option mappings.
Add following dictionary/hashSet definitions.

  • CanonicalNames
  • MultiValueOptionNames
  • ScalarValueOptionNames

To avoid using reflection.
These mappings are manually edited (And mappings consistencies are validated by unit tests)

3. Modify ConfigParser.cs and add validation logics for duplicated scalar options.
By default, when scalar option are specified multiple times. It's overwritten by last parameter.
To keep existing behavior, add logics to validate these cases.

4. Add ConfigParser related tests.

This branch has not been deployed

No deployments
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.

1 participant