perf(cli): speed up startup
This commit is contained in:
15
src/cli/program/program-context.ts
Normal file
15
src/cli/program/program-context.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { Command } from "commander";
|
||||
import type { ProgramContext } from "./context.js";
|
||||
|
||||
const PROGRAM_CONTEXT_SYMBOL: unique symbol = Symbol.for("openclaw.cli.programContext");
|
||||
|
||||
export function setProgramContext(program: Command, ctx: ProgramContext): void {
|
||||
(program as Command & { [PROGRAM_CONTEXT_SYMBOL]?: ProgramContext })[PROGRAM_CONTEXT_SYMBOL] =
|
||||
ctx;
|
||||
}
|
||||
|
||||
export function getProgramContext(program: Command): ProgramContext | undefined {
|
||||
return (program as Command & { [PROGRAM_CONTEXT_SYMBOL]?: ProgramContext })[
|
||||
PROGRAM_CONTEXT_SYMBOL
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user