mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-10 04:02:50 +00:00
fix(cli): preserve equals in root option values
This commit is contained in:
committed by
clawsweeper
parent
d7083bab4c
commit
a4bef79bfe
29
src/cli/root-option-value.test.ts
Normal file
29
src/cli/root-option-value.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { takeCliRootOptionValue } from "./root-option-value.js";
|
||||
|
||||
describe("takeCliRootOptionValue", () => {
|
||||
it("preserves equals signs after the first separator", () => {
|
||||
expect(takeCliRootOptionValue("--token=abc=def", undefined)).toEqual({
|
||||
value: "abc=def",
|
||||
consumedNext: false,
|
||||
});
|
||||
expect(takeCliRootOptionValue("--token=abc==", undefined)).toEqual({
|
||||
value: "abc==",
|
||||
consumedNext: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("treats empty inline values as missing", () => {
|
||||
expect(takeCliRootOptionValue("--token=", "fallback")).toEqual({
|
||||
value: null,
|
||||
consumedNext: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("continues to consume the next token for space-separated values", () => {
|
||||
expect(takeCliRootOptionValue("--token", "abc=def")).toEqual({
|
||||
value: "abc=def",
|
||||
consumedNext: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -8,7 +8,7 @@ export function takeCliRootOptionValue(
|
||||
consumedNext: boolean;
|
||||
} {
|
||||
if (raw.includes("=")) {
|
||||
const [, value] = raw.split("=", 2);
|
||||
const value = raw.slice(raw.indexOf("=") + 1);
|
||||
const trimmed = (value ?? "").trim();
|
||||
return { value: trimmed || null, consumedNext: false };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user