-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
37 lines (31 loc) · 772 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
35
36
37
#!/usr/bin/env node
import help from './lib/help.js';
import { graceful } from './lib/utils.js';
import {
run,
compile,
anallify,
stringify,
} from './lib/std.js';
import {
RUN,
HELP,
COMPILE,
ANALLIFY,
STRINGIFY,
} from './lib/constants.js';
function cli() {
let output = '';
const command = process.argv[2];
const args = process.argv.slice(3, process.argv.length).join('');
switch (command) {
case COMPILE: compile(args); break;
case RUN: output = run(args); break;
case HELP: process.stdout.write(help); return;
case ANALLIFY: output = anallify(args); break;
case STRINGIFY: output = stringify(args); break;
default: process.stdout.write(help); return;
}
process.stdout.write(`${output}\n`);
}
graceful(cli);