forked from matklad/matklad.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
48 lines (43 loc) · 854 Bytes
/
main.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
import { build, watch } from "./build.ts";
const params = {
update: false,
spell: false,
profile: false,
filter: "",
};
const subcommand = Deno.args[0];
var i = 1;
for (; i < Deno.args.length; i++) {
switch (Deno.args[i]) {
case "--update": {
params.update = true;
break;
}
case "--spell": {
params.spell = true;
break;
}
case "--profile": {
params.profile = true;
break;
}
case "--filter": {
params.filter = Deno.args[i + 1] ?? "";
i++;
break;
}
default:
fatal(`unexpected argument: ${Deno.args[i]}`);
}
}
if (subcommand === "build") {
await build(params);
} else if (subcommand === "watch") {
await watch(params);
} else {
fatal("subcommand required");
}
function fatal(message: string) {
console.error(message);
Deno.exit(1);
}