0
私はいくつかのコマンドを持っており、それらはすべて同じオプションを使用しています。例えばcommander.jsを使用して他のコマンドで定義されたオプションを再利用できますか?
..
program.command('hello')
.option('--foo <name>', 'this is the foo option and requires a name')
.option('--bar', 'this is the bar option and takes no arguments')
.action(options => {
// do stuff here...
});
program.command('world')
.option('--foo <name>', 'this is the foo option and requires a name')
.option('--bar', 'this is the bar option and takes no arguments')
.action(options => {
// do stuff here...
});
私はこれをリファクタリングし、一度オプションを定義したいと思います。ただし、各コマンドで実行されるアクションは異なる場合があります。
オプションを一度宣言し、定義された/ allコマンドで使用する方法はありますか?