fix(cli): fixup invalid args validation (#1099)

This commit is contained in:
James George 2020-01-02 20:26:57 +05:30 committed by Gregor Martynus
parent f90057e9b0
commit e0d3072751
1 changed files with 7 additions and 5 deletions

View File

@ -14,11 +14,13 @@ program
.usage('<command> [options]')
.command('run', 'run the bot')
.command('receive', 'Receive a single event and payload')
program.on('command:*', (cmd) => {
console.log(`\nInvalid command ${cmd}\n`)
program.outputHelp()
})
.on('command:*', (cmd) => {
if (!program.commands.find(c => c._name == cmd[0])) {
console.error(`Invalid command: ${program.args.join(' ')}\n`);
program.outputHelp()
process.exit(1);
}
})
program
.parse(process.argv)