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

Function main

packages/cli/src/index.ts:81–125  ·  view source on GitHub ↗
(argv: string[] = process.argv.slice(2))

Source from the content-addressed store, hash-verified

79}
80
81export async function main(argv: string[] = process.argv.slice(2)): Promise<number> {
82 if (argv.length === 0 || argv[0] === "--help" || argv[0] === "-h" || argv[0] === "help") {
83 printUsage();
84 return 0;
85 }
86
87 if (argv[0] === "--version" || argv[0] === "-v") {
88 console.log(getVersion());
89 return 0;
90 }
91
92 const command = argv[0];
93 const rest = argv.slice(1);
94
95 if (command === "setup") {
96 const { runSetup } = await import("./commands/setup");
97 return runSetup(rest);
98 }
99
100 if (command === "doctor") {
101 if (rest[0] === "migrate") {
102 const { runMigrateCli } = await import("./commands/migrate");
103 return runMigrateCli(rest.slice(1));
104 }
105 if (rest[0] === "migrate-session") {
106 const { runMigrateSessionCli } = await import("./commands/migrate-session");
107 return runMigrateSessionCli(rest.slice(1));
108 }
109 const { runDoctor } = await import("./commands/doctor");
110 const rekeyV22DirIdentity = valueAfter(rest, "--rekey-v22-dir-identity");
111 return runDoctor({
112 force: rest.includes("--force"),
113 issue: rest.includes("--issue"),
114 clear: rest.includes("--clear"),
115 checkV22Backfill: rest.includes("--check-v22-backfill"),
116 retryV22Backfill: rest.includes("--retry-v22-backfill"),
117 ...(rekeyV22DirIdentity !== null ? { rekeyV22DirIdentity } : {}),
118 argv: rest,
119 });
120 }
121
122 console.error(`Unknown command: ${command}`);
123 printUsage();
124 return 1;
125}
126
127main().then((code) => process.exit(code));

Callers 1

index.tsFile · 0.70

Calls 8

getVersionFunction · 0.85
runMigrateCliFunction · 0.85
runMigrateSessionCliFunction · 0.85
errorMethod · 0.80
printUsageFunction · 0.70
valueAfterFunction · 0.70
runSetupFunction · 0.50
runDoctorFunction · 0.50

Tested by

no test coverage detected