Repository navigation
Conversation
`-p a -p b` is now bound to ["a", "b"] instead of only the last value. Each occurrence is parsed as before (JSON / comma-separated / custom parser) and appended in order. params T[] and [Argument] T[] are not affected. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
LGTM,
Minor/optional: |
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.
Closes #263. Follow-up to #81 and #239.
What changed
A
T[]option can now be specified more than once. Each occurrence is parsed exactly as before (JSON / comma-separated / custom parser) and the values are appended in order. Previously the last occurrence silently won.-p a["a"]["a"]-p a -p b["b"]["a", "b"]-p a,b -p c["c"]["a", "b", "c"]-p [1,2] -p 3[3][1, 2, 3]-p a --prop b(alias)["b"]["a", "b"]How
The parse code itself (
BuildParseMethod,TrySplitParse) is untouched. The emitter wraps the existing parse statement of a named array option with two lines:null, soprev != nulltells whether the option has already appeared. NoList<T>, no extra flag; a combined array is allocated only when the option really is repeated.argis not touched, sostring[]? x = nullstaysnull.ISpanParsable<T>elements, JSON elements (classes, enums) and custom parsers (IArgumentParser<T[]>) all behave the same.Scope
T[].params T[](consumes all remaining arguments) and[Argument] T[](positional).AddGlobalOption<T>does not support arrays.Values containing commas
Comma-separated parsing per occurrence is kept for compatibility, so
-p List=a,bis still split. No new attribute is added for this: a custom parser forT[]that does not split is enough, and since each occurrence is appended, repeating still works. The README "Array" section shows it:Notes for reviewers
ConcatArrayreturns the other array as is when one side is empty, and treats anullsecond array (JSONnull) as empty.Tests
ArrayParseTestgets 8 new tests: repeated / interleaved / comma mixed / JSON mixed /[]mixed / ignore-case mixed, aliases,nulldefault kept, required error and parse failure in a later occurrence, JSON element types (class and enum arrays), custom parser,ConsoleApp.Create()withAddandAdd<T>, and[Argument] T[]not being merged.srcchange.🤖 Generated with Claude Code