Commit cc545c5
fix(cli): error on unknown command root when --help/--version is appended (#81077)
openclaw <unknown-command> --help silently fell through to generic top-level help and exited 0, while the same openclaw <unknown-command> (no --help) correctly errored with "Unknown command" and exited 1. The asymmetry was caused by two short-circuits on invocation.hasHelpOrVersion: resolveUnownedCliPrimary bailed before the unknown-primary check, and the only caller was gated on !isHelpOrVersionInvocation.
Drop the hasHelpOrVersion bail in resolveUnownedCliPrimary so the helper continues to validate the primary when --help or --version is present, and add an unconditional caller in runCli after the root and browser help fast paths so legitimate help (openclaw --help, openclaw status --help, openclaw browser --help) still dispatches normally while unknown roots error consistently regardless of trailing flags.
Verified:
- pnpm test src/cli/run-main.exit.test.ts src/cli/argv.test.ts src/cli/argv-invocation.test.ts (76 passed)
- pnpm exec oxfmt --check --threads=1 src/cli/run-main.ts src/cli/run-main.exit.test.ts (clean)
- pnpm build && node openclaw.mjs heartbeat --help (exit 1, Unknown command error)
- pnpm build && node openclaw.mjs status --help (exit 0, status help renders)
- pnpm build && node openclaw.mjs browser --help (exit 0, browser help renders)
- pnpm build && node openclaw.mjs --help (exit 0, root help renders)
Closes #810771 parent c339980 commit cc545c5
2 files changed
Lines changed: 33 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
507 | 527 | | |
508 | 528 | | |
509 | 529 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
370 | | - | |
371 | 370 | | |
372 | 371 | | |
373 | 372 | | |
| |||
541 | 540 | | |
542 | 541 | | |
543 | 542 | | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
544 | 556 | | |
545 | 557 | | |
546 | 558 | | |
| |||
0 commit comments