-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimal.ts
71 lines (58 loc) · 1.7 KB
/
minimal.ts
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// ---------- process Polyfill -----------
const process = {
argv: [
'/home/vexcess/.nvm/versions/node/v20.16.0/bin/node',
'/usr/local/bin/lnstat.js',
'./'
],
stdout: {
write: print
}
};
// ---------- ----------
// ---------- Zig Bindings ----------
const init = $SHBuiltin.extern_c({ include: "fs-polyfill.h" }, function init(): void {
throw 0;
});
// ---------- ----------
// ---------- More Polyfills ----------
// NOTE: shermes does not support Array.prototype.slice
function Array_slice(self: string[], start: number, stop: number): string[] {
let subArr = [];
for (let i = start; i < stop; i++) {
subArr.push(self[i]);
}
return subArr;
}
// ---------- ----------
init();
function showHelp() {
}
function main() {
print("checkpoint 1")
print(process.argv.length)
const args = Array_slice([
'/home/vexcess/.nvm/versions/node/v20.16.0/bin/node',
'/usr/local/bin/lnstat.js',
'./'
], 2, 3);
let excludeRegexes = [];
let filterRegexes = [];
print("checkpoint 2")
print(args.length)
for (let i = 0; i < args.length; i++) {
print(args[i]);
const arg = new String(args[i]);
print("checkpoint 2.5")
if (arg.startsWith("--exclude=") || arg.startsWith("-e=")) {
excludeRegexes.push(new RegExp(arg.slice(arg.indexOf("=") + 1)));
} else if (arg.startsWith("--filter=") || arg.startsWith("-f=")) {
filterRegexes.push(new RegExp(arg.slice(arg.indexOf("=") + 1)));
} else if (arg === "--help" || arg === "-h" || arg === "-help") {
showHelp();
return;
}
}
print("checkpoint 3");
}
main();