






















@@ -16,6 +16,7 @@ import {
1616isRootVersionInvocation,
1717normalizeGeneratedHelpCommandArgv,
1818normalizeRootHelpTargetArgv,
19+normalizeRootNoColorArgv,
1920shouldMigrateState,
2021shouldMigrateStateFromPath,
2122} from "./argv.js";
@@ -171,6 +172,61 @@ describe("argv helpers", () => {
171172expect(normalizeRootHelpTargetArgv(argv)).toEqual(expected);
172173});
173174175+it.each([
176+{
177+name: "subcommand trailing no-color",
178+argv: ["node", "openclaw", "doctor", "--no-color", "--post-upgrade", "--json"],
179+expected: ["node", "openclaw", "--no-color", "doctor", "--post-upgrade", "--json"],
180+},
181+{
182+name: "keeps existing root options first",
183+argv: ["node", "openclaw", "--profile", "work", "doctor", "--no-color", "--lint", "--json"],
184+expected: [
185+"node",
186+"openclaw",
187+"--profile",
188+"work",
189+"--no-color",
190+"doctor",
191+"--lint",
192+"--json",
193+],
194+},
195+{
196+name: "keeps no-color after possible command option value",
197+argv: ["node", "openclaw", "doctor", "--lint", "--json", "--no-color"],
198+expected: ["node", "openclaw", "doctor", "--lint", "--json", "--no-color"],
199+},
200+{
201+name: "flag terminator leaves no-color positional",
202+argv: ["node", "openclaw", "doctor", "--", "--no-color"],
203+expected: ["node", "openclaw", "doctor", "--", "--no-color"],
204+},
205+{
206+name: "command option value remains literal",
207+argv: ["node", "openclaw", "agent", "--message", "--no-color"],
208+expected: ["node", "openclaw", "agent", "--message", "--no-color"],
209+},
210+{
211+name: "assigned command option value does not block no-color",
212+argv: ["node", "openclaw", "agent", "--message=hello", "--no-color"],
213+expected: ["node", "openclaw", "--no-color", "agent", "--message=hello"],
214+},
215+])("normalizes root --no-color before command parsing: $name", ({ argv, expected }) => {
216+expect(normalizeRootNoColorArgv(argv)).toEqual(expected);
217+});
218+219+it("allows final command metadata to lift no-color after boolean command flags", () => {
220+const argv = ["node", "openclaw", "doctor", "--lint", "--json", "--no-color"];
221+222+expect(
223+normalizeRootNoColorArgv(argv, {
224+shouldPreserveNoColor: ({ remainingArgs, noColorIndex }) =>
225+remainingArgs[noColorIndex - 1] === "--message",
226+}),
227+).toEqual(["node", "openclaw", "--no-color", "doctor", "--lint", "--json"]);
228+});
229+174230it.each([
175231{
176232name: "root help command",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。