-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
executable file
·38 lines (33 loc) · 1012 Bytes
/
index.js
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
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env node
'use strict';
const program = require('commander');
const chalk = require("chalk");
const boxen = require("boxen");
const action = require('./action');
const pkg = require('./package.json');
const simpleCommands = require('./commands.json');
const complexCommands = require('./commands/index.js')(program, action.stdExec, chalk);
const R = require('ramda');
program.version(pkg.version);
simpleCommands.forEach(command => {
program
.command(command.cli)
.alias(command.alias)
.description(chalk.yellow(command.description))
.action(() => {
action.stdExec({
cmd: command.cmd,
color: typeof command.color === 'undefined' ? true : command.color
}).then(x => {
console.log(boxen(x, {padding: 1, borderColor: "yellow"}));
})
})
});
program.on('*', function () {
console.log('Unknown Command: ' + program.args.join(' '));
program.help();
});
program.on('help', function () {
program.help();
});
program.parse(process.argv);