mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 01:11:36 +00:00
perf(cli): speed up help/config paths and route config get/unset
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { rewriteUpdateFlagArgv } from "./run-main.js";
|
||||
import {
|
||||
rewriteUpdateFlagArgv,
|
||||
shouldRegisterPrimarySubcommand,
|
||||
shouldSkipPluginCommandRegistration,
|
||||
} from "./run-main.js";
|
||||
|
||||
describe("rewriteUpdateFlagArgv", () => {
|
||||
it("leaves argv unchanged when --update is absent", () => {
|
||||
@@ -34,3 +38,46 @@ describe("rewriteUpdateFlagArgv", () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldRegisterPrimarySubcommand", () => {
|
||||
it("skips eager primary registration for help/version invocations", () => {
|
||||
expect(shouldRegisterPrimarySubcommand(["node", "openclaw", "status", "--help"])).toBe(false);
|
||||
expect(shouldRegisterPrimarySubcommand(["node", "openclaw", "-V"])).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps eager primary registration for regular command runs", () => {
|
||||
expect(shouldRegisterPrimarySubcommand(["node", "openclaw", "status"])).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldSkipPluginCommandRegistration", () => {
|
||||
it("skips plugin registration for root help/version", () => {
|
||||
expect(
|
||||
shouldSkipPluginCommandRegistration({
|
||||
argv: ["node", "openclaw", "--help"],
|
||||
primary: null,
|
||||
hasBuiltinPrimary: false,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("skips plugin registration for builtin subcommand help", () => {
|
||||
expect(
|
||||
shouldSkipPluginCommandRegistration({
|
||||
argv: ["node", "openclaw", "config", "--help"],
|
||||
primary: "config",
|
||||
hasBuiltinPrimary: true,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps plugin registration for non-builtin help", () => {
|
||||
expect(
|
||||
shouldSkipPluginCommandRegistration({
|
||||
argv: ["node", "openclaw", "voicecall", "--help"],
|
||||
primary: "voicecall",
|
||||
hasBuiltinPrimary: false,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user