yargs / yargs-parser

:muscle: the mighty option parser used by yargs
http://yargs.js.org/
ISC License
493 stars 119 forks source link

interpreting space after parameter as boolean use #380

Open smhg opened 3 years ago

smhg commented 3 years ago

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:

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 commented 3 years ago

Additionally, the short version acts in a similar way:

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 commented 3 years ago

@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 commented 3 years ago

@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.