Add shared parseBooleanValue()/isTruthyEnvValue() and apply across CLI, gateway, memory, and live-test flags for consistent env handling. Introduce route-first fast paths, lazy subcommand registration, and deferred plugin loading to reduce CLI startup overhead. Centralize config validation via ensureConfigReady() and add config caching/deferred shell env fallback for fewer IO passes. Harden logger initialization/imports and add focused tests for argv, boolean parsing, frontmatter, and CLI subcommands.
20 lines
633 B
TypeScript
20 lines
633 B
TypeScript
import type { Command } from "commander";
|
|
import { emitCliBanner } from "../banner.js";
|
|
|
|
function setProcessTitleForCommand(actionCommand: Command) {
|
|
let current: Command = actionCommand;
|
|
while (current.parent && current.parent.parent) {
|
|
current = current.parent;
|
|
}
|
|
const name = current.name();
|
|
if (!name || name === "clawdbot") return;
|
|
process.title = `clawdbot-${name}`;
|
|
}
|
|
|
|
export function registerPreActionHooks(program: Command, programVersion: string) {
|
|
program.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
setProcessTitleForCommand(actionCommand);
|
|
emitCliBanner(programVersion);
|
|
});
|
|
}
|