Skip to content

Commit ca76353

Browse files
bug fix 🚧
1 parent 9fac9ce commit ca76353

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/commands/main.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import program from 'commander';
22
import pjson from '../../package.json';
33
import chalk from 'chalk';
44

5+
const availableCommands = ['init', 'list', 'search', 'info'];
6+
57
program
68
.version(pjson.version)
79
.option('-v, --version', 'check version')
@@ -11,13 +13,16 @@ program
1113
.command('search [term]', 'Search for MERN variant')
1214
.command('info [term]', 'View details of a MERN variant')
1315
.arguments('<command>')
14-
.action((cmd) => {
15-
program.outputHelp()
16-
console.log(` ` + chalk.yellow(`\n Unknown command ${chalk.green(cmd)}`))
17-
console.log()
18-
})
1916
.parse(process.argv);
2017

18+
if (program.args.length >= 1) {
19+
if (!availableCommands.includes(program.args[0])) {
20+
program.outputHelp()
21+
console.log(` ` + chalk.red(`\n Unknown command ${chalk.yellow(program.args[0])}.`))
22+
console.log()
23+
}
24+
}
25+
2126
if (!program.args.length) {
2227
program.help();
2328
}

0 commit comments

Comments
 (0)