mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-28 05:16:17 +00:00
fix: route nested root help targets
This commit is contained in:
@@ -151,6 +151,21 @@ describe("argv helpers", () => {
|
||||
argv: ["node", "openclaw", "help", "--help"],
|
||||
expected: ["node", "openclaw", "help", "--help"],
|
||||
},
|
||||
{
|
||||
name: "nested root help target",
|
||||
argv: ["node", "openclaw", "help", "plugins", "list"],
|
||||
expected: ["node", "openclaw", "plugins", "list", "--help"],
|
||||
},
|
||||
{
|
||||
name: "nested root help target with help flag",
|
||||
argv: ["node", "openclaw", "help", "plugins", "list", "--help"],
|
||||
expected: ["node", "openclaw", "plugins", "list", "--help"],
|
||||
},
|
||||
{
|
||||
name: "nested root help target with trailing root option",
|
||||
argv: ["node", "openclaw", "help", "memory", "status", "--no-color"],
|
||||
expected: ["node", "openclaw", "--no-color", "memory", "status", "--help"],
|
||||
},
|
||||
])("normalizes root help targets: $name", ({ argv, expected }) => {
|
||||
expect(normalizeRootHelpTargetArgv(argv)).toEqual(expected);
|
||||
});
|
||||
|
||||
@@ -245,13 +245,13 @@ export function normalizeRootHelpTargetArgv(argv: string[]): string[] {
|
||||
if (
|
||||
help?.value !== "help" ||
|
||||
!target ||
|
||||
positionals.length !== 2 ||
|
||||
(helpFlagIndex !== null && helpFlagIndex !== target.index + 1)
|
||||
(helpFlagIndex !== null && helpFlagIndex !== positionals.at(-1)!.index + 1)
|
||||
) {
|
||||
return argv;
|
||||
}
|
||||
|
||||
return [argv[0], argv[1], ...rootOptions, target.value, "--help"];
|
||||
const targetPath = positionals.slice(1).map((positional) => positional.value);
|
||||
return [argv[0], argv[1], ...rootOptions, ...targetPath, "--help"];
|
||||
}
|
||||
|
||||
export function getFlagValue(argv: string[], name: string): string | null | undefined {
|
||||
|
||||
Reference in New Issue
Block a user