feat: warn on passing in unknown commands

This commit is contained in:
jamesgeorge007 2019-12-25 08:41:58 +05:30 committed by Gregor Martynus
parent 5b86e1bb6a
commit f368013729
1 changed files with 9 additions and 1 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
const semver = require('semver') const semver = require('semver')
const program = require('commander')
const version = require('../package').engines.node const version = require('../package').engines.node
if (!semver.satisfies(process.version, version)) { if (!semver.satisfies(process.version, version)) {
@ -8,9 +9,16 @@ if (!semver.satisfies(process.version, version)) {
process.exit(1) process.exit(1)
} }
require('commander') program
.version(require('../package').version) .version(require('../package').version)
.usage('<command> [options]') .usage('<command> [options]')
.command('run', 'run the bot') .command('run', 'run the bot')
.command('receive', 'Receive a single event and payload') .command('receive', 'Receive a single event and payload')
program.on('command:*', (cmd) => {
console.log(`\nInvalid command ${cmd}\n`)
program.outputHelp()
})
program
.parse(process.argv) .parse(process.argv)