mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 19:14:33 +00:00
CLI: resolve parent/subcommand option collisions (#18725)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: b7e51cf909
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
committed by
GitHub
parent
fa4f66255c
commit
985ec71c55
45
src/cli/acp-cli.option-collisions.test.ts
Normal file
45
src/cli/acp-cli.option-collisions.test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Command } from "commander";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const runAcpClientInteractive = vi.fn(async () => {});
|
||||
const serveAcpGateway = vi.fn(async () => {});
|
||||
|
||||
const defaultRuntime = {
|
||||
error: vi.fn(),
|
||||
exit: vi.fn(),
|
||||
};
|
||||
|
||||
vi.mock("../acp/client.js", () => ({
|
||||
runAcpClientInteractive: (opts: unknown) => runAcpClientInteractive(opts),
|
||||
}));
|
||||
|
||||
vi.mock("../acp/server.js", () => ({
|
||||
serveAcpGateway: (opts: unknown) => serveAcpGateway(opts),
|
||||
}));
|
||||
|
||||
vi.mock("../runtime.js", () => ({
|
||||
defaultRuntime,
|
||||
}));
|
||||
|
||||
describe("acp cli option collisions", () => {
|
||||
beforeEach(() => {
|
||||
runAcpClientInteractive.mockClear();
|
||||
serveAcpGateway.mockClear();
|
||||
defaultRuntime.error.mockClear();
|
||||
defaultRuntime.exit.mockClear();
|
||||
});
|
||||
|
||||
it("forwards --verbose to `acp client` when parent and child option names collide", async () => {
|
||||
const { registerAcpCli } = await import("./acp-cli.js");
|
||||
const program = new Command();
|
||||
registerAcpCli(program);
|
||||
|
||||
await program.parseAsync(["acp", "client", "--verbose"], { from: "user" });
|
||||
|
||||
expect(runAcpClientInteractive).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
verbose: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user