La situationComment fournir des options à travers de nombreuses commandes avec Node.js commandant
Je fournissent de nombreuses commandes, comme ceci:
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
});
Le problème
Avis Je dois répète mes déclarations d'option. J'ai beaucoup d'options et ceci crée la répétition.
En outre, ces options ne seront pas visibles dans mon -h "aide" Sortie:
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
La question
Comment puis-je déclarer les options qu'une seule fois, de les appliquer à tous commandes, et les faire apparaître dans l'aide -h?