Fix positional arguments not populated when halt-at-non-option is set#2524
Open
ordinary9843 wants to merge 1 commit into
Open
Fix positional arguments not populated when halt-at-non-option is set#2524ordinary9843 wants to merge 1 commit into
ordinary9843 wants to merge 1 commit into
Conversation
shadowspawn
reviewed
Apr 7, 2026
Comment on lines
+551
to
+553
| // When halt-at-non-option is configured, yargs-parser places positional | ||
| // arguments in argv['--'] instead of argv._. Move them into argv._ so | ||
| // positional validation and mapping work correctly. |
Member
There was a problem hiding this comment.
It turns out the -- storage is on purpose.
I fear simply moving the arguments between properties will interact with other behaviours and combinations of options. In particular if caller has set "populate--": true.
Aside: the ongoing cost we pay for letting yargs users configure yargs-parser!
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.
When
halt-at-non-optionis configured,yargs-parserplaces all positional arguments intoargv['--']instead ofargv._. ThepopulatePositionalsfunction incommand.tsreads onlyargv._.lengthfor its required-argument count check and usesargv._exclusively when mapping positionals to their named keys. This means that even when the correct number of positionals is provided, the validation reports "Not enough non-option arguments: got 0, need at least 1" and no positional values are populated.This fix detects when
halt-at-non-optionis active andargv['--']has content, then merges those entries intoargv._before validation and mapping run. Both the count check and the positional population now see the correct arguments.Fixes #2423