Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow flags to parse arrays without variadic modifier #25

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

molisani
Copy link
Member

Resolves #21

Describe your changes
Prior to this change, any flag type that extended from readonly (infer A)[] would be interpreted as a variadic parameter. The variadic modifier allows the flag to be specified multiple times, each input parsed separately, and the results returned as an array. However, this did not allow for the use case that a single parsed value (i.e. --flag=a,b,c) could produce an array as output (["a", "b", "c"]).

With this change, the variadic modifier can be dropped from flags with an array-based type and the parser will then expect that exact array-based type as output.

Testing performed
Updated both formatting and scanner tests to confirm the new behavior.

Additional context
This also allows for the possibility of accepting specific array-based types as flags, such as subclasses of TypedArray (types that are not only Array).

@molisani molisani self-assigned this Oct 19, 2024
@molisani molisani requested a review from a team as a code owner October 19, 2024 20:21
@molisani molisani added the core ⚙ Relates to the @stricli/core package label Oct 20, 2024
@mkubilayk mkubilayk merged commit ecc9099 into main Oct 22, 2024
3 checks passed
@mkubilayk mkubilayk deleted the fix/parsed-arrays branch October 22, 2024 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core ⚙ Relates to the @stricli/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make variadic optional for array types
2 participants