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

interpreting space after parameter as boolean use #380

Open
smhg opened this issue Apr 18, 2021 · 3 comments
Open

interpreting space after parameter as boolean use #380

smhg opened this issue Apr 18, 2021 · 3 comments
Labels

Comments

@smhg
Copy link

smhg commented Apr 18, 2021

This is probably not an issue, but rather a question:

The existing translation tool xgettext (part of GNU gettext-tools) allows these different usages of their --keyword parameter:

  • xgettext --keyword=foo --keyword=bar source.js
    Scans source.js for foo, bar and the default keywords (_, gettext,... for JavaScript files).
  • xgettext --keyword=foo --keyword=bar --keyword source.js
    Scans source.js for only foo and bar, ignoring the default keywords.

The --keyword parameter is acting both as a boolean and as an array of strings. The use of an equal-sign is mandatory when specifying a string value.

Is something similar possible with yargs?

@smhg smhg changed the title boolean option with optional string value interpreting space after parameter as boolean use Apr 18, 2021
@smhg
Copy link
Author

smhg commented Apr 18, 2021

Additionally, the short version acts in a similar way:

  • xgettext -kfoo -kbar source.js
  • xgettext -kfoo -kbar -k source.js

In this case too a space after the parameter is considered to signal boolean use. xgettext -k foo would cause foo to be interpreted as the source file, ignoring default keywords.

@bcoe bcoe transferred this issue from yargs/yargs Apr 25, 2021
@bcoe
Copy link
Member

bcoe commented Apr 25, 2021

@smhg today I do not believe there is a way to differentiate between an argument set with = and one set with a space.

I could imagine us adding some additional meta information like this to the object returned after parsing.

@smhg
Copy link
Author

smhg commented Apr 25, 2021

@bcoe thank you for your reply!
It would be nice to use in an xgettext companion project (gmarty/xgettext) but I can't tell if this pattern is common. Absolutely feel free to close/archive this issue.

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