diff --git a/src/commands/main.js b/src/commands/main.js index a51a41c..dea0d7c 100644 --- a/src/commands/main.js +++ b/src/commands/main.js @@ -1,5 +1,8 @@ import program from 'commander'; import pjson from '../../package.json'; +import chalk from 'chalk'; + +const availableCommands = ['init', 'list', 'search', 'info']; program .version(pjson.version) @@ -9,7 +12,16 @@ program .command('list', 'List MERN variants') .command('search [term]', 'Search for MERN variant') .command('info [term]', 'View details of a MERN variant') - .parse(process.argv); + .arguments('') + .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();