forked from QwikDev/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
47 lines (40 loc) · 1.66 KB
/
Copy pathindex.ts
File metadata and controls
47 lines (40 loc) · 1.66 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
import { Program } from "../../core.ts";
import pm from "panam/pm";
type HelpArgs = { _: string[] };
type HelpInput = Record<string, never>;
/** List of all CLI commands with descriptions (ARCH-08) */
export const COMMAND_LIST: { name: string; description: string }[] = [
{ name: "add", description: "Add an integration to this app" },
{ name: "build", description: "Build the application" },
{ name: "build preview", description: 'Same as "build", but for preview server' },
{ name: "new", description: "Create a new component or route" },
{ name: "joke", description: "Tell a random dad joke" },
{ name: "migrate-v2", description: "Migrate to Qwik v2" },
{ name: "check-client", description: "Check client build freshness" },
{ name: "help", description: "Show help for all commands" },
{ name: "version", description: "Print CLI version" },
];
export class HelpProgram extends Program<HelpArgs, HelpInput> {
protected configure(): void {
this.registerCommand("help", "Show help for all commands");
}
/** Override parse to return empty args without invoking yargs (avoids yargs --help interception) */
protected async parse(_argv: string[]): Promise<HelpArgs> {
return { _: [] };
}
protected validate(_definition: HelpArgs): HelpInput {
return {};
}
protected async execute(_input: HelpInput): Promise<number> {
const pmRun = pm.runCommand();
console.log("Available commands:\n");
for (const cmd of COMMAND_LIST) {
console.log(` ${cmd.name.padEnd(18)} ${cmd.description}`);
}
console.log("");
console.log(`Usage: ${pmRun} qwik [command]`);
console.log("");
return 0;
}
}
export default HelpProgram;