Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn users for firing in unknown commands #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/commands/main.js
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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('<command>')
.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();
Expand Down