-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·51 lines (48 loc) · 1.43 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
'use strict';
const program = require('commander');
const packageJson = require('./package.json');
// console.log(packageJson);
// Provide a title to the process in `ps`
process.title = 'batman-cli';
const {
exec,
initConfig,
list
} = require("./lib");
const {
colors
} = require('./lib/utils');
const printHelp = () => {
program.outputHelp(colors.magenta);
};
program
.version(packageJson.version);
program
.command('init')
.alias('i')
.description('initialize batman configuration, "For more help: $ batman init -h"')
.option("-c, --config <path>", "set config path for batman cli. default to ./batman.config.js || ./.batmanrc.json")
.option("-js, --js", "defualt is json")
.action(initConfig);
program
.command('exec <cmd>')
.alias('run')
.description('Execute the given command <cmd>, "For more help: $ batman exec -h"')
.action(exec);
program
.command('list')
.alias('ls')
.description('List commands, "For more help: $ batman list -h"')
.option("-f, --full", "prints command with actual executable, defualt is false")
.option("-n, --npm", "prints command including npm, defualt is false")
.option("-j, --json", "prints command in json format, defualt is false")
.action(list);
program
.command('*')
.description('Command not found')
.action(printHelp);
program.parse(process.argv);
if (!process.argv.slice(2).length) {
printHelp();
}