initial cli api, some movement on tool selection

This commit is contained in:
2025-04-24 20:27:09 -06:00
parent 08bba857db
commit 7d42920dcb
18 changed files with 938 additions and 180 deletions

33
cli/argParser.ts Normal file
View File

@@ -0,0 +1,33 @@
export class ArgParser {
private args: string[];
constructor(args: string[]) {
this.args = args;
}
public get(key: string) {
const index = this.args.indexOf(key);
if (index === -1) return null;
return this.args[index + 1];
}
get flags() {
return this.args.filter((arg) => arg.startsWith("-"));
}
get nonFlags() {
return this.args.filter((arg) => !arg.startsWith("-"));
}
get namedArgs() {
return this.args.filter((arg) => arg.startsWith("--"));
}
get task() {
return this.nonFlags[0];
}
static parse(args: string[]) {
return new ArgParser(args);
}
}