-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
65 lines (53 loc) · 1.34 KB
/
main.ts
File metadata and controls
65 lines (53 loc) · 1.34 KB
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
/**
* @module
*
* This module is the entry point for the crunchwrap CLI.
* It handles command-line arguments and dispatches to the appropriate commands.
*
* @example
* ```bash
* deno run -A main.ts init
* ```
*/
import { red } from "@std/fmt/colors";
import { initCommand } from "./init.ts";
import { newLogoCommand } from "./new-logo.ts";
import { newPwaImagesCommand } from "./new-pwa-images.ts";
import denoConfig from "./deno.json" with { type: "json" };
const args = Deno.args;
if (args.includes("--version") || args.includes("-v")) {
console.log(denoConfig.version);
Deno.exit(0);
}
if (args.includes("--help") || args.includes("-h") || args.length === 0) {
console.log(`
Crunchwrap App CLI (v${denoConfig.version})
Usage:
cw init
cw new-logo
cw new-pwa-images
Options:
-v, --version Show version
-h, --help Show help
Commands:
init Initialize a new Crunchwrap app
new-logo Generate a new logo with AI for an existing app
new-pwa-images Generate PWA images from an existing image
`);
Deno.exit(0);
}
const cmd = args[0];
if (cmd === "init") {
await initCommand();
Deno.exit(0);
}
if (cmd === "new-logo") {
await newLogoCommand();
Deno.exit(0);
}
if (cmd === "new-pwa-images") {
await newPwaImagesCommand();
Deno.exit(0);
}
console.error(red(`Unknown command: ${cmd}`));
Deno.exit(1);