CLI argv: test root version fast-path detection

This commit is contained in:
Vincent Koc
2026-03-01 12:06:36 -08:00
parent 153adc4c8f
commit 07da843378

View File

@@ -8,6 +8,7 @@ import {
getVerboseFlag,
hasHelpOrVersion,
hasFlag,
isRootVersionInvocation,
shouldMigrateState,
shouldMigrateStateFromPath,
} from "./argv.js";
@@ -63,6 +64,36 @@ describe("argv helpers", () => {
expect(hasHelpOrVersion(argv)).toBe(expected);
});
it.each([
{
name: "root --version",
argv: ["node", "openclaw", "--version"],
expected: true,
},
{
name: "root -V",
argv: ["node", "openclaw", "-V"],
expected: true,
},
{
name: "root -v alias with profile",
argv: ["node", "openclaw", "--profile", "work", "-v"],
expected: true,
},
{
name: "subcommand version flag",
argv: ["node", "openclaw", "status", "--version"],
expected: false,
},
{
name: "unknown root flag with version",
argv: ["node", "openclaw", "--unknown", "--version"],
expected: false,
},
])("detects root-only version invocations: $name", ({ argv, expected }) => {
expect(isRootVersionInvocation(argv)).toBe(expected);
});
it.each([
{
name: "single command with trailing flag",