test: cover the CLI argument parser#448
Conversation
The CLI parse layer in src/core/cli.ts is pure, deterministic logic but sat at 82% line coverage, with help-text branches, validation, and error paths untested. Add tests driving parseCli directly across every command's --help output, layout/positive-integer validation, unknown-command and unsupported-subcommand errors, session selector and reload-target conflicts, and the full `session comment apply` stdin-payload validators. Coverage rises to ~99%; the remaining lines are defensive (commander help is always pre-intercepted). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Greptile SummaryThis PR adds 30 new unit tests for
Confidence Score: 5/5Test-only change with no production code modifications; safe to merge. All new assertions were cross-checked against the production paths in cli.ts and resolve correctly. The withStdin helper properly guards stdin restoration in a try/finally, the applyWithPayload helper is scoped correctly, and each validation test targets the exact error message produced by the corresponding guard. No production behavior is altered. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "test: cover the CLI argument parser" | Re-trigger Greptile |
What
Adds unit coverage for
src/core/cli.ts, the CLI argument parser. It was pure, deterministic logic but sat at 82.4% line coverage — help-text branches, validation, and error paths were untested. This lifts it to 99.7% (the 3 remaining lines are unreachable defensive code: commander's help is always pre-intercepted).30 new tests (53 → 83), all driving
parseCli(...)directly — no daemons, binaries, or flakiness:diff,show,patch,pager,difftool,stash/stash show,daemon/daemon serve,skill/skill path,sessionand each oflist/get/navigate/reload/commentplus the five comment subcommands).--hunk, commander unknown-option rethrow, ambiguous diff input, conflicting session selectors, unknown skill/daemon/stash/comment subcommands, comment-add target rules, andcomment rmtarget-count rules for both selector styles.session reload: missing nested command, no target, all three selector conflicts, and the three non-reloadable nested kinds (pager / nested session / stdin patch).session comment applystdin payload: the full validator surface — empty/invalid JSON, non-object root, missingcommentsarray, non-object entry, missingfilePath/summary, bad hunk selector, and the no-selector case.Verification
bun run typecheck✅bun run lint✅ (0 warnings)bun run format:check✅Test-only; no user-visible change (empty changeset included).
🤖 Generated with Claude Code