Also habe ich mehrere Befehle und sie alle verwenden die gleichen Optionen.Können Sie Optionen, die in anderen Befehlen definiert sind, mit commander.js wiederverwenden?
Zum Beispiel ..
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...
});
Ich möchte das Refactoring und die Optionen einmal definieren. Die für jeden Befehl ausgeführten Aktionen können jedoch abweichen.
Gibt es eine Möglichkeit, Optionen einmal zu deklarieren und sie für alle definierten Befehle zu verwenden?