From 33e073daea5494edf1cb95ceaa4d47375dce3348 Mon Sep 17 00:00:00 2001 From: James George Date: Fri, 28 Dec 2018 22:59:06 +0530 Subject: [PATCH] bug fix :construction: --- src/commands/main.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/commands/main.js b/src/commands/main.js index 398623e..dea0d7c 100644 --- a/src/commands/main.js +++ b/src/commands/main.js @@ -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') @@ -11,13 +13,16 @@ program .command('search [term]', 'Search for MERN variant') .command('info [term]', 'View details of a MERN variant') .arguments('') - .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(); }