feat(inquirerer): add positional arguments support with _ property #35
+660
−1
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.
feat(inquirerer): add positional arguments support with _ property
Summary
This PR adds the ability to "name positional parameters" in inquirerer. Questions marked with
_: truecan receive values fromargv._(minimist's positional array) without requiring the--nameflag.Example usage:
Key behaviors:
--name value) take precedence over positional valuesresult._- remaining extras stay in the arrayUpdates since last revision
Fixed
mutateArgsbehavior and added positional stripping:extractPositionalArgsnow returns the count of consumed positionalsresult._(e.g.,{ _: ['a', 'b', 'c'] }with one positional question becomes{ _: ['b', 'c'], first: 'a' })mutateArgs: true(default): originalargv._is also strippedmutateArgs: false: originalargvis completely untouched (deep clone of_array)Review & Testing Checklist for Human
argv._. Test thatnode app.js a b cwith one positional question results in{ first: 'a', _: ['b', 'c'] }- confirm this is the expected behavior for your use casesmutateArgs: falseisolation: Verify that withmutateArgs: false, the originalargvobject (includingargv._) is completely unchanged afterprompt()returnsminimist(process.argv.slice(2))output, not just test fixturesRecommended test plan:
result._contains only unconsumed positional valuesmutateArgs: falseand confirm original argv is unchangedNotes
Devin session: https://app.devin.ai/sessions/43a1b03d22ef47bb866a272558cf3809
Requested by: Dan Lynch (@pyramation)