|
8 | 8 | getVerboseFlag, |
9 | 9 | hasHelpOrVersion, |
10 | 10 | hasFlag, |
| 11 | + isRootHelpRequest, |
11 | 12 | isRootVersionRequest, |
12 | 13 | shouldMigrateState, |
13 | 14 | shouldMigrateStateFromPath, |
@@ -332,4 +333,55 @@ describe("argv helpers", () => { |
332 | 333 | ])("isRootVersionRequest: $name", ({ argv, expected }) => { |
333 | 334 | expect(isRootVersionRequest(argv)).toBe(expected); |
334 | 335 | }); |
| 336 | + |
| 337 | + // isRootHelpRequest: guards the entry.ts fast-path help exit. |
| 338 | + it.each([ |
| 339 | + { |
| 340 | + name: "--help flag at root", |
| 341 | + argv: ["node", "openclaw", "--help"], |
| 342 | + expected: true, |
| 343 | + }, |
| 344 | + { |
| 345 | + name: "-h flag at root", |
| 346 | + argv: ["node", "openclaw", "-h"], |
| 347 | + expected: true, |
| 348 | + }, |
| 349 | + { |
| 350 | + name: "--help after a root boolean flag", |
| 351 | + argv: ["node", "openclaw", "--dev", "--help"], |
| 352 | + expected: true, |
| 353 | + }, |
| 354 | + { |
| 355 | + name: "--help after a root value flag", |
| 356 | + argv: ["node", "openclaw", "--profile", "dev", "--help"], |
| 357 | + expected: true, |
| 358 | + }, |
| 359 | + { |
| 360 | + name: "--help after -- terminator must NOT trigger (forwarded arg)", |
| 361 | + argv: ["node", "openclaw", "nodes", "run", "--", "git", "--help"], |
| 362 | + expected: false, |
| 363 | + }, |
| 364 | + { |
| 365 | + name: "-h after -- terminator must NOT trigger", |
| 366 | + argv: ["node", "openclaw", "--", "-h"], |
| 367 | + expected: false, |
| 368 | + }, |
| 369 | + { |
| 370 | + name: "--help with subcommand must NOT trigger (subcommand-scoped)", |
| 371 | + argv: ["node", "openclaw", "status", "--help"], |
| 372 | + expected: false, |
| 373 | + }, |
| 374 | + { |
| 375 | + name: "-h with subcommand must NOT trigger", |
| 376 | + argv: ["node", "openclaw", "models", "-h"], |
| 377 | + expected: false, |
| 378 | + }, |
| 379 | + { |
| 380 | + name: "normal command without help flag", |
| 381 | + argv: ["node", "openclaw", "status"], |
| 382 | + expected: false, |
| 383 | + }, |
| 384 | + ])("isRootHelpRequest: $name", ({ argv, expected }) => { |
| 385 | + expect(isRootHelpRequest(argv)).toBe(expected); |
| 386 | + }); |
335 | 387 | }); |
0 commit comments