`boolean-negation` + `unknown-options-as-args` strange behaviour
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 519
- Forks
- 129
- Avg merge
- 1h 34m
- Merged PRs (30d)
- 1
Description
Node.js: v14.15.2
yargs-parser: v20.2.7
const yargsParser = require('yargs-parser');
const opts = {
string: ['asd'],
configuration: {
'boolean-negation': false,
'camel-case-expansion': false,
'unknown-options-as-args': true,
},
};
console.log(yargsParser('--no-asd2 123', opts)); // { _: [ '--no-asd2', 123 ] }
console.log(yargsParser('--no-asd 123', opts)); // { _: [], 'no-asd': 123 }
Is it correct behaviour? Because of 'boolean-negation': false I was expecting similar output { _: [ '--no-asd', 123 ] }.
Fixed that by adding 'negation-prefix': Math.random().toString(36).slice(2) to configuration. But that would be better to fix it under the hood :) Thanks!
UPD: even 'negation-prefix': '' works fine.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the yargs-parser configuration handling exercised by the Node.js reproduction, focusing on boolean-negation, negation-prefix, and unknown-options-as-args. Run both shown command-line examples and compare their parsed objects; done means the behavior matches the documented configuration expectations without requiring a random negation-prefix workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100