-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
nbbun.js
executable file
·38 lines (29 loc) · 730 Bytes
/
nbbun.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 bun
import { loadString, loadFile, addClassPath } from './index.mjs';
import { existsSync } from "fs";
const prn = await loadString('prn');
const nonNil = await loadString('some?');
var args = process.argv.slice(2);
if (args[0] === '--classpath') {
addClassPath(args[[1]]);
args = args.slice(2);
}
if (args[0] === '-e') {
let res = await(loadString(args[1]));
if (nonNil(res)) {
prn(res);
}
args = args.slice(2);
}
if (args[0] === '--help') {
console.log(`Usage: nbbun <opts> <file>
Options:
--classpath: set classpath.
-e <expr>: run expressions and print result.
--help: print this help.
`);
}
if (args[0] && existsSync(args[0])) {
await(loadFile(args[0]));
args = args.slice(2);
}