We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This is with yargs v16.0.1.
Sample code in test.js:
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.
-
stdin
stdout
The text was updated successfully, but these errors were encountered:
So far the only workaround I've found is to use '"-"' as the argument. This preserves it as a positional argument.
'"-"'
Sorry, something went wrong.
Add note about option-like arguments to alter filter
2bf04d1
The Yargs parser doesn't seem to play nicely with option-like arguments that are passed as positional arguments. For more information, refer to the following issues: yargs/yargs-parser#381 yargs/yargs-parser#145 yargs/yargs#1821
This may be an issue in yargs rather than yargs-parser. There is a test that dash is supported as a positional in yargs-parser:
yargs-parser/test/yargs-parser.cjs
Line 1496 in 3aba24c
Related: yargs/yargs#1312
No branches or pull requests
This is with yargs v16.0.1.
Sample code in
test.js
:Test:
This is unfortunate, as using
-
as a filename to meanstdin
orstdout
is a common convention.The text was updated successfully, but these errors were encountered: