-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
executable file
·51 lines (47 loc) · 1.36 KB
/
app.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
#!/usr/bin/env -S pkgx deno^2 run -A
//TODO if you step into dev-dir/subdir and type `dev` does it find the root properly?
//TODO dev off uses PWD which may not be correct if in subdir (obv)
import { Path } from "libpkgx";
import shellcode from "./src/shellcode().ts";
import app_version from "./src/app-version.ts";
import integrate from "./src/integrate.ts";
import { parse } from "jsr:@std/flags";
import dump from "./src/dump.ts";
const parsedArgs = parse(Deno.args, {
alias: {
n: "dry-run",
"just-print": "dry-run",
recon: "dry-run",
v: "version",
h: "help",
},
boolean: ["help", "version", "shellcode"],
default: {
"dry-run": false,
},
});
if (parsedArgs.help) {
const status = await new Deno.Command("pkgx", {
args: ["gh", "repo", "view", "pkgxdev/dev"],
}).spawn().status;
Deno.exit(status.code);
} else if (parsedArgs.shellcode) {
console.log(shellcode());
} else if (parsedArgs.version) {
console.log(`dev ${app_version}`);
} else {
const subcommand = parsedArgs._[0];
const dryrun = parsedArgs["dry-run"] as boolean;
switch (subcommand) {
case "integrate":
await integrate("install", { dryrun });
break;
case "deintegrate":
await integrate("uninstall", { dryrun });
break;
default: {
const cwd = Path.cwd().join(subcommand as string);
await dump(cwd, { dryrun });
}
}
}