Closed austencollins closed 8 years ago
Use vorpal.parse()
, and don't use vorpal.show()
.
vorpal.show
actually starts the interactive CLI. If you don't run it, the app will just exit. vorpal.parse
takes the passed in CLI args and runs a given Vorpal command.
If you want to run a command you created on the fly without having the user pass in any args, you can use vorpal.exec('said command')
.
Does this help?
I can confirm this works. This is how I am doing it.
const app = vorpal();
if (process.argv.length > 2) {
app.parse(process.argv);
}
else {
app.execSync('help');
// You could also call app.delimeter('custom:').show()
}
@dthree you probably close this.
Maybe something has changed, but this does not work for me. Calling "parse" parses one command, then stays in the CLI, even without a "show."
The code in the SO answer works for me, only because it forgets to call the callback at the end of the command! However, if I type any other command as an argument, it stays in the CLI after parse() completes.
How can we turn off the session functionality, or immediately exit after a single command?