mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 15:20:43 +00:00
fix(cli): preserve lazy command parent flags
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { Command } from "commander";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { collectOption, parsePositiveIntOrUndefined, resolveActionArgs } from "./helpers.js";
|
||||
import {
|
||||
collectOption,
|
||||
parsePositiveIntOrUndefined,
|
||||
resolveActionArgs,
|
||||
resolveCommandOptionArgs,
|
||||
} from "./helpers.js";
|
||||
|
||||
describe("program helpers", () => {
|
||||
it("collectOption appends values in order", () => {
|
||||
@@ -38,4 +43,46 @@ describe("program helpers", () => {
|
||||
expect(resolveActionArgs(command)).toEqual([]);
|
||||
expect(resolveActionArgs(undefined)).toEqual([]);
|
||||
});
|
||||
|
||||
it("resolveCommandOptionArgs serializes explicit options", () => {
|
||||
const command = new Command()
|
||||
.option("--json", "JSON output", false)
|
||||
.option("--timeout <ms>", "Timeout", "30000")
|
||||
.option("--tag <name>", "Tag", collectOption)
|
||||
.option("--no-progress", "Disable progress");
|
||||
|
||||
command.parse([
|
||||
"node",
|
||||
"test",
|
||||
"--json",
|
||||
"--timeout",
|
||||
"10",
|
||||
"--tag",
|
||||
"a",
|
||||
"--tag",
|
||||
"b",
|
||||
"--no-progress",
|
||||
]);
|
||||
|
||||
expect(resolveCommandOptionArgs(command)).toEqual([
|
||||
"--json",
|
||||
"--timeout",
|
||||
"10",
|
||||
"--tag",
|
||||
"a",
|
||||
"--tag",
|
||||
"b",
|
||||
"--no-progress",
|
||||
]);
|
||||
});
|
||||
|
||||
it("resolveCommandOptionArgs skips defaults", () => {
|
||||
const command = new Command()
|
||||
.option("--json", "JSON output", false)
|
||||
.option("--timeout <ms>", "Timeout", "30000");
|
||||
|
||||
command.parse(["node", "test"]);
|
||||
|
||||
expect(resolveCommandOptionArgs(command)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user