-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathmain.js
More file actions
28 lines (24 loc) · 847 Bytes
/
main.js
File metadata and controls
28 lines (24 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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')
.description('Initialize a MERN powered project')
.command('init [name]', 'Initialize a MERN project.')
.command('list', 'List MERN variants')
.command('search [term]', 'Search for MERN variant')
.command('info [term]', 'View details of a MERN variant')
.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();
}