mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-24 23:23:33 +00:00
CLI: add fuzzy selector when no command is given
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
shouldEnsureCliPath,
|
||||
shouldRegisterPrimarySubcommand,
|
||||
shouldSkipPluginCommandRegistration,
|
||||
shouldUseInteractiveCommandSelector,
|
||||
} from "./run-main.js";
|
||||
|
||||
describe("rewriteUpdateFlagArgv", () => {
|
||||
@@ -103,6 +104,64 @@ describe("shouldSkipPluginCommandRegistration", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldUseInteractiveCommandSelector", () => {
|
||||
it("enables selector for plain no-arg interactive invocations", () => {
|
||||
expect(
|
||||
shouldUseInteractiveCommandSelector({
|
||||
argv: ["node", "openclaw"],
|
||||
stdinIsTTY: true,
|
||||
stdoutIsTTY: true,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("disables selector when a command is already present", () => {
|
||||
expect(
|
||||
shouldUseInteractiveCommandSelector({
|
||||
argv: ["node", "openclaw", "status"],
|
||||
stdinIsTTY: true,
|
||||
stdoutIsTTY: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("disables selector for non-interactive terminals or CI", () => {
|
||||
expect(
|
||||
shouldUseInteractiveCommandSelector({
|
||||
argv: ["node", "openclaw"],
|
||||
stdinIsTTY: false,
|
||||
stdoutIsTTY: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
shouldUseInteractiveCommandSelector({
|
||||
argv: ["node", "openclaw"],
|
||||
stdinIsTTY: true,
|
||||
stdoutIsTTY: true,
|
||||
ciEnv: "1",
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
shouldUseInteractiveCommandSelector({
|
||||
argv: ["node", "openclaw"],
|
||||
stdinIsTTY: true,
|
||||
stdoutIsTTY: true,
|
||||
disableSelectorEnv: "1",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("disables selector for help/version invocations", () => {
|
||||
expect(
|
||||
shouldUseInteractiveCommandSelector({
|
||||
argv: ["node", "openclaw", "--help"],
|
||||
stdinIsTTY: true,
|
||||
stdoutIsTTY: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldEnsureCliPath", () => {
|
||||
it("skips path bootstrap for help/version invocations", () => {
|
||||
expect(shouldEnsureCliPath(["node", "openclaw", "--help"])).toBe(false);
|
||||
|
||||
Reference in New Issue
Block a user