Single dash passed as positional arg disappears
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- cli
Research direction
Start with the reproduction in test.js and run both node test.js - and node test.js a to confirm the differing positional values. Trace the yargs-parser handling of a lone dash, then add a regression test showing that - remains the positional foo value and verify the existing parser tests still pass.
Written by the indexing model from the issue text.
Description
This is with yargs v16.0.1.
Sample code in test.js:
const yargs = require('yargs/yargs')
const {hideBin} = require('yargs/helpers');
const argv = yargs(hideBin(process.argv))
.command('$0 <foo>', 'the default command', (yargs) => {
yargs
.positional('foo', {type: 'string', required: true})
}, (argv) => {
console.log(argv)
})
.argv
Test:
$ node test.js -
{ _: [], '$0': 'test.js', foo: '' }
$ node test.js a
{ _: [], '$0': 'test.js', foo: 'a' }
This is unfortunate, as using - as a filename to mean stdin or stdout is a common convention.
- Dominant language
- JavaScript
- Stars
- 519
- Forks
- 129
- Avg merge
- 1h 34m
- Merged PRs (30d)
- 1
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.
More from yargs/yargs-parser
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
yargs/yargs-parser#518 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
yargs/yargs-parser#506 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
yargs/yargs-parser#484 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
yargs/yargs-parser#468 · 1 comment ·
-
bug p2
Difficulty 3/5 1-2 days Newbie friendliness 55/100
yargs/yargs-parser#445 · 1 comment ·
All issues in yargs/yargs-parser
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·