Skip to content

Commit

Permalink
When user runs unknown command, show the help
Browse files Browse the repository at this point in the history
Closes #178

Also something to investigate would be to do a fuzzy search
for what the user intended to type and suggest that:

tj/commander.js#432 (comment)
  • Loading branch information
KyleAMathews committed Mar 8, 2016
1 parent 98d6bb2 commit 938d9f0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bin/index.js
@@ -1,6 +1,9 @@
/*eslint-disable */
var program = require('commander')
var packageJson = require('../package.json')
var _ = require('lodash')
var subCmd
var cmds
/*eslint-enable */

program
Expand All @@ -9,3 +12,11 @@ program
.command('build [directory]', 'Do a production build of site')
.command('new [rootPath] [starter]', 'Create new Gatsby project in path [.].')
.parse(process.argv)

// If the user types an unknown sub-command, just display the help.
subCmd = _.head(program.args)
cmds = _.map(program.commands, '_name')

if (!_.includes(cmds, subCmd)) {
program.help()
}

0 comments on commit 938d9f0

Please sign in to comment.