vorpal
vorpal copied to clipboard
subcommands in mode
is there a recommended way to do subcommands for modes?
maybe include an example of what you want to do?
is this similar to your issue? https://github.com/dthree/vorpal/issues/289
@NonPolynomial did you find a good pattern or did you give up?
it would be awesome to have an example for this, like the sub-commands in commanderjs examples
I've looked at the code of cash to see a working example
config.commands.forEach(cmd => {
try {
const mod = require(`../lib/commands/${cmd}`)
program.use(mod);
} catch (e) {
program.log(`Error loading command ${cmd}: `, e);
}
})
but on the sub-commands files I do this:
module.exports = (program, options) => {
program
.command('foo list')
.action((args, callback) => {
callback();
});
program
.command('foo scan')
.action((args, callback) => {
callback();
});
}
but.. I've understood from this issue that the mode needs to be refactored in order to show the sub-commands as a stand-alone cli.
I don't know if it can help but I've almost archived what I wanted.