-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.ts
More file actions
executable file
·39 lines (30 loc) · 959 Bytes
/
Copy pathcli.ts
File metadata and controls
executable file
·39 lines (30 loc) · 959 Bytes
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
#!/usr/bin/env bun
import { cancel } from "@clack/prompts";
import { COMMAND_REGISTRY } from "./src/commands/registry.ts";
import { loadCommand } from "./src/utils/command-loader.ts";
import { endSectionError, endSectionSuccess } from "./src/utils/logger.ts";
async function main(): Promise<void> {
const command = Bun.argv[2];
if (!command) {
cancel("No command provided. Run `help` for usage.");
process.exit(1);
}
const loaded = await loadCommand(command, COMMAND_REGISTRY);
if (loaded.isErr()) {
cancel(loaded.error);
endSectionError("Failed");
process.exit(1);
}
const result = await loaded.value.run(Bun.argv.slice(3));
if (result.isErr()) {
cancel(result.error);
endSectionError("Failed");
process.exit(1);
}
endSectionSuccess("Done");
}
main().catch((error: unknown) => {
cancel(error instanceof Error ? error.message : String(error));
endSectionError("Failed");
process.exit(1);
});