-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Add a booleanish
option
#44
Comments
I like the idea in general and I've had the same problem previously too, but not entirely sold on this exact implementation. Why not just let the user specify an option as both const cli = meow('help', {
any: ['debug']
});
No flag and |
Is this supported? |
This came up while implementing the
--debug
flag for AVA.Basically, there are two ways to use the debug flag:
The reason you can't use the last one is because it's ambiguous whether you meant "run two test files with the default port" or "run one file with port 1234".
When you specify the flag as boolean:
You get
true
orfalse
regardless. However you must specify it as a boolean, or this:To be interpreted as:
My solution was to set
debug
up as aboolean
, then if I gottrue
, reparse argv to find the portI think it might be interesting to allow this:
The basic usage of the
booleanish
option is:true
: What gets returned if it is used as a boolean flag--debug
false
: What gets returned if no flag appears (or--no-debug
is used).parse
: If they use the--debug=XXX
- this function is used to parse theXXX
part. It can throw an Error for invalid values, andmeow
should print the Error message, and exit.This would greatly ease the creation of dual purpose flags that can be used either as simple booleans, or be supplied with a config value.
The text was updated successfully, but these errors were encountered: