-
Notifications
You must be signed in to change notification settings - Fork 30
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
Feature: Handle unary boolean option #112
Comments
Hey @chabou try this: #110 (comment) args
.option(['v', 'verbose'], 'Enable verbose mode', false)
.option(['s', 'sound'], 'Enable sound', true)
const flags = args.parse(process.argv, {
mri: {
boolean: ['v', 's']
},
version: false
})
console.log('flags: ', flags)
console.log('sub: ', args.sub) $ node args.js --v /tmp
flags: { v: true, verbose: true, s: true, sound: true }
sub: [ '/tmp' ]
$ node args.js --no-sound /tmp
flags: { v: false, verbose: false, s: false, sound: false }
sub: [ '/tmp' ] Note: in order to get the |
Thank you for this tip 😍 But are you interested to have a PR to manage this directly in |
Actually, that would be awesome! Yes please. |
In case of boolean option, it would be useful to have this option with true value if it is passed as argument with no value.
Bonus: it should be compatible with
--no-<option>
to set it false.Example:
# Should give /tmp as args.sub $ myscript -v /tmp $ myscript --no-sound /tmp
The text was updated successfully, but these errors were encountered: