The Situation
I provide many commands, like this:
program
.command('foo-command')
.description('Do foo things')
.option('-s, --staging', 'Tells the system to use the staging instance')
.option('-c, --certroot <path>', 'Path to the certoot')
.action(function(optional) {
//do foo things
});
program
.command('bar-command')
.description('Do bar things')
.option('-s, --staging', 'Tells the system to use the staging instance')
.option('-c, --certroot <path>', 'Path to the certoot')
.action(function(optional) {
//do bar things
});
The Problem
Notice I have to repeat my option declarations. I have many options and this creates repetition.
Also, these options won't show up in my -h "help" output:
Usage: cert_manager [options] [command]
Commands:
generate Any CMS websites without an SSL cert will have a cert created and it will be uploaded to our CDN
renew Any SSL cert that is about to expire will be renewed and re-uploaded to our CDN
Options:
-h, --help output usage information
The Question
How Can I declare options only once, have them apply to all commands, and have them show up in the -h help?
via lance.dolan
No comments:
Post a Comment