-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
First of all, great library!
Consider this code:
const {program} = require('commander');
program
.option('-p, --pizza [type]', 'Pizza name', 'pepperoni')
.parse(process.argv)
console.log({pizza: program.pizza});
Usage:
$ script.js
# Output: { pizza: 'pepperoni' }
$ script.js --pizza
# Output: { pizza: 'pepperoni' }
$ script.js --pizza salami
# Output: { pizza: 'salami' }
Is there a way to see if the --pizza
flag is actually used? Currently the default-value is always present and used, even if the flag itself is not even present in the arguments. This makes it impossible to pre-process values and making the flag optional as at this point the flag is neither optional or mandatory, it is always there, even if not specified.
Do I miss something or how can I achieve that using commanderjs?
Metadata
Metadata
Assignees
Labels
No labels