perf(cli): speed up startup

This commit is contained in:
Peter Steinberger
2026-02-14 12:16:16 +00:00
parent a7a08b6650
commit c90b3e4d5e
8 changed files with 223 additions and 44 deletions

View File

@@ -93,9 +93,16 @@ export async function runCli(argv: string[] = process.argv) {
});
const parseArgv = rewriteUpdateFlagArgv(normalizedArgv);
// Register the primary subcommand if one exists (for lazy-loading)
// Register the primary command (builtin or subcli) so help and command parsing
// are correct even with lazy command registration.
const primary = getPrimaryCommand(parseArgv);
if (primary && shouldRegisterPrimarySubcommand(parseArgv)) {
if (primary) {
const { getProgramContext } = await import("./program/program-context.js");
const ctx = getProgramContext(program);
if (ctx) {
const { registerCoreCliByName } = await import("./program/command-registry.js");
await registerCoreCliByName(program, ctx, primary, parseArgv);
}
const { registerSubCliByName } = await import("./program/register.subclis.js");
await registerSubCliByName(program, primary);
}