Skip to content
New issue

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

option narg does not behave as documented #2442

Open
bschick opened this issue Nov 17, 2024 · 1 comment
Open

option narg does not behave as documented #2442

bschick opened this issue Nov 17, 2024 · 1 comment
Labels

Comments

@bschick
Copy link

bschick commented Nov 17, 2024

Problem

nargs options config does not consume values starting with - as documented

Expected Results

The docs describe nargs to work like this:

var argv = require('yargs/yargs')(process.argv.slice(2))
  .nargs('token', 1)
  .parse(['--token', '-my-token']);

parses as:
{ _: [], token: '-my-token', '$0': 'node test' }

Actual Result

yargs 17.7.2 instead does not consume the -my-token and returns an error:

Options:
--help Show help [boolean]
--version Show version number [boolean]

Not enough arguments following: token

@shadowspawn
Copy link
Member

You are right. The documentation is out of date. The default behaviour in yargs-parser changed quite a while ago and the documentation in yargs has not been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants