Skip to content

Commit cb2284e

Browse files
committed
feat: implement add command list and install flows
1 parent b9b7c2f commit cb2284e

3 files changed

Lines changed: 683 additions & 3 deletions

File tree

‎src/cli.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bun
22
import { cac } from "cac";
3+
import { runAddCommand } from "./commands/add";
34
import { runFindCommand } from "./commands/find";
45
import { runInitCommand } from "./commands/init";
56

@@ -48,7 +49,11 @@ function toGlobalFlags(options: CommandOptions): GlobalFlags {
4849
};
4950
}
5051

51-
function runCommand(command: CommandName, args: string[], flags: GlobalFlags): number {
52+
async function runCommand(command: CommandName, args: string[], flags: GlobalFlags): Promise<number> {
53+
if (command === "add") {
54+
return runAddCommand(args, { yes: flags.yes, verbose: flags.verbose });
55+
}
56+
5257
if (command === "find") {
5358
return runFindCommand(args, { verbose: flags.verbose });
5459
}
@@ -68,8 +73,8 @@ function runCommand(command: CommandName, args: string[], flags: GlobalFlags): n
6873
function addCommand(command: CommandName): void {
6974
cli
7075
.command(`${command} [...args]`, COMMAND_HELP[command])
71-
.action((args: string[], options: CommandOptions) => {
72-
const exitCode = runCommand(command, args, toGlobalFlags(options));
76+
.action(async (args: string[], options: CommandOptions) => {
77+
const exitCode = await runCommand(command, args, toGlobalFlags(options));
7378
process.exitCode = exitCode;
7479
});
7580
}

0 commit comments

Comments
 (0)