feat(cli): add "testsprite completion" for bash/zsh/fish#184
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughAdds shell completion support for bash, zsh, and fish. The new command detects or accepts a shell, builds completion output from the live Commander tree, and prints a generated script. Tests cover helper behavior, rendering, and command execution. ChangesShell completion feature
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CompletionCommand
participant Index
participant Renderer
User->>CompletionCommand: testsprite completion [shell]
CompletionCommand->>CompletionCommand: isShell(shell) / detectShell($SHELL)
CompletionCommand->>Index: buildCompletionSpec()
Index-->>CompletionCommand: CompletionSpec
CompletionCommand->>Renderer: renderCompletion(shell, spec)
Renderer-->>CompletionCommand: completion script text
CompletionCommand-->>User: stdout(script)
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/commands/completion.test.ts (1)
57-91: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider covering stdout/stderr separation.
Per path instructions, machine output must go to stdout while human chatter/hints go to stderr. The tests only assert on injected
stdoutcapture; there's no coverage ensuring validation error messages or hints for an unsupported/undetected shell are routed to stderr rather than stdout.As per path instructions, "human chatter, hints, and advisories go to stderr" for src/** files.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/commands/completion.test.ts` around lines 57 - 91, The completion command tests only verify stdout output, but they should also cover that validation errors and hints are emitted to stderr for unsupported or undetected shells. Update createCompletionCommand test coverage in createCompletionCommand and its parseAsync cases by injecting a stderr sink alongside stdout, then assert that normal completion script output stays on stdout while error/advisory messaging is routed to stderr for the failing scenarios.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/commands/completion.test.ts`:
- Around line 57-91: The completion command tests only verify stdout output, but
they should also cover that validation errors and hints are emitted to stderr
for unsupported or undetected shells. Update createCompletionCommand test
coverage in createCompletionCommand and its parseAsync cases by injecting a
stderr sink alongside stdout, then assert that normal completion script output
stays on stdout while error/advisory messaging is routed to stderr for the
failing scenarios.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3017b8d1-d345-4207-906d-86b4c843bd19
⛔ Files ignored due to path filters (1)
test/__snapshots__/help.snapshot.test.ts.snapis excluded by!**/*.snap,!**/*.snap
📒 Files selected for processing (3)
src/commands/completion.test.tssrc/commands/completion.tssrc/index.ts
|
Approved on content — |
Emit a shell completion script for bash, zsh, or fish. Command names, subcommands, and global flags are derived from the fully-assembled Commander tree at call time (buildCompletionSpec walks program.commands), so the script can never drift from the real command surface. The shell auto-detects from $SHELL when the argument is omitted. Fixes TestSprite#74
|
Rebased onto current main. Ready to merge. |
Adds
testsprite completion [bash|zsh|fish]: prints a shell completion script.Command names, per-group subcommands, and global flags are NOT hardcoded: index.ts walks the fully-assembled Commander program (buildCompletionSpec) and passes a CompletionSpec in, so the generated script can never drift from the real command tree. renderCompletion is a pure function of the spec (unit-testable without a live program). The shell auto-detects from $SHELL when omitted.
Enable it:
eval "$(testsprite completion bash)" # bash
testsprite completion zsh > ~/.zsh/_testsprite
testsprite completion fish | source # fish
Fixes #74
Summary by CodeRabbit
New Features
completioncommand to generate shell completion scripts.bash,zsh, andfish, with automatic shell detection when available (or erroring on unsupported/unknown shells).Tests