Skip to content

Commit

Permalink
bug fix 🚧
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Dec 28, 2018
1 parent 9fac9ce commit 33e073d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/commands/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import program from 'commander';
import pjson from '../../package.json';
import chalk from 'chalk';

const availableCommands = ['init', 'list', 'search', 'info'];

program
.version(pjson.version)
.option('-v, --version', 'check version')
Expand All @@ -11,13 +13,16 @@ program
.command('search [term]', 'Search for MERN variant')
.command('info [term]', 'View details of a MERN variant')
.arguments('<command>')
.action((cmd) => {
program.outputHelp()
console.log(` ` + chalk.yellow(`\n Unknown command ${chalk.green(cmd)}`))
console.log()
})
.parse(process.argv);

if (program.args.length >= 1) {
if (!availableCommands.includes(program.args[0])) {
program.outputHelp()
console.log(` ` + chalk.red(`\n Unknown command ${chalk.yellow(program.args[0])}.`))
console.log()
}
}

if (!program.args.length) {
program.help();
}

0 comments on commit 33e073d

Please sign in to comment.