-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcli.js
executable file
·34 lines (27 loc) · 879 Bytes
/
cli.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
#!/usr/bin/env node
const clarg = require('clarg');
const promptForInput = require('./lib/cli/promptForInput');
const parseInput = require('./lib/cli/parseInput');
/**
* CLI entry point
*
* If arguments are specified (at least mode of operation and database)
* this will dispatch straight to the process and execute it.
*
* Otherwise it'll produce an interactive prompt to get data from the user.
*
* Listens on the process arguments - this should not be imported programmatically.
*/
function main() {
if (require.main !== module) {
return console.log('This file is meant to be executed directly in terminal.');
}
const cliArgs = clarg();
const mode = cliArgs && cliArgs.args && cliArgs.args.length ? cliArgs.args[0] : false;
const opts = cliArgs.opts;
if (!mode) {
return promptForInput();
}
return parseInput({ mode, opts });
}
main();