MCPcopy Create free account
hub / github.com/cortexkit/magic-context / parseMigrateArgs

Function parseMigrateArgs

packages/cli/src/commands/migrate.ts:1030–1048  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

1028}
1029
1030export function parseMigrateArgs(args: string[]): MigrateCliOptions {
1031 const opts: MigrateCliOptions = {};
1032 for (let i = 0; i < args.length; i++) {
1033 const arg = args[i];
1034 const readValue = (flag: string): string => {
1035 const value = args[++i];
1036 if (!value || value.startsWith("--")) throw new Error(`Missing value for ${flag}`);
1037 return value;
1038 };
1039 if (arg === "--from") opts.from = readValue(arg);
1040 else if (arg === "--to") opts.to = readValue(arg);
1041 else if (arg === "--session") opts.session = readValue(arg);
1042 else if (arg === "--max-messages") opts.maxMessages = Number(readValue(arg));
1043 else if (arg === "--dry-run") opts.dryRun = true;
1044 else if (arg === "--help" || arg === "-h") throw new Error("HELP");
1045 else throw new Error(`Unknown migrate flag: ${arg}`);
1046 }
1047 return opts;
1048}
1049
1050export function printMigrateHelp(): void {
1051 console.log(`

Callers 2

migrate.test.tsFile · 0.90
runMigrateCliFunction · 0.85

Calls 1

readValueFunction · 0.85

Tested by

no test coverage detected