feat: add jmp completion command for bash/zsh/fish#334
feat: add jmp completion command for bash/zsh/fish#334mangelajo merged 6 commits intojumpstarter-dev:mainfrom
Conversation
Resolves jumpstarter-dev#319 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✅ Deploy Preview for jumpstarter-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant jmp_CLI as jmp (Click)
participant ClickLib as Click Completion
participant Stdout
User->>jmp_CLI: run "jmp completion --shell <bash|zsh|fish>"
jmp_CLI->>ClickLib: get_completion_class(shell) & instantiate with jmp context
ClickLib->>Stdout: comp.source() (completion script)
Stdout->>User: completion script printed
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
python/packages/jumpstarter-cli/jumpstarter_cli/completion_test.py (2)
29-38: Assert error messages for invalid usage paths.For Line 32 and Line 38, adding message checks would verify that failures are for the expected reason, not just any parse error.
Proposed error-path assertion strengthening
def test_completion_no_args(): runner = CliRunner() result = runner.invoke(jmp, ["completion"]) assert result.exit_code == 2 + assert "Missing argument" in result.output @@ def test_completion_unsupported_shell(): runner = CliRunner() result = runner.invoke(jmp, ["completion", "powershell"]) assert result.exit_code == 2 + assert "Invalid value" in result.output🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@python/packages/jumpstarter-cli/jumpstarter_cli/completion_test.py` around lines 29 - 38, Update the two tests to assert the specific error/output text so failures are for the expected reason: in test_completion_no_args() after invoking jmp with ["completion"] check result.exit_code == 2 and assert that result.output (or result.stderr) contains the missing-argument/usage text (e.g. contains "Missing" or "Usage" or "SHELL") to prove it failed due to no shell arg; in test_completion_unsupported_shell() after invoking jmp with ["completion", "powershell"] assert exit_code == 2 and that result.output contains the unsupported-choice text and the literal "powershell" (or "Invalid choice") so the failure is due to an unsupported shell, referencing the test functions test_completion_no_args and test_completion_unsupported_shell and the jmp completion invocation.
6-27: Tighten success-path assertions to reduce false positives.The current checks are a bit permissive (especially Line 11 with
"comp"). Consider asserting shell-specific markers plus non-empty output.Proposed test assertion tightening
def test_completion_bash(): runner = CliRunner() result = runner.invoke(jmp, ["completion", "bash"]) assert result.exit_code == 0 - assert len(result.output) > 0 - assert "complete" in result.output.lower() or "comp" in result.output.lower() + assert result.output.strip() + assert "complete" in result.output.lower() + assert "jmp" in result.output.lower() @@ def test_completion_zsh(): runner = CliRunner() result = runner.invoke(jmp, ["completion", "zsh"]) assert result.exit_code == 0 - assert len(result.output) > 0 + assert result.output.strip() + assert "compdef" in result.output.lower() @@ def test_completion_fish(): runner = CliRunner() result = runner.invoke(jmp, ["completion", "fish"]) assert result.exit_code == 0 - assert len(result.output) > 0 + assert result.output.strip() assert "complete" in result.output.lower() + assert " -c jmp" in result.output.lower()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@python/packages/jumpstarter-cli/jumpstarter_cli/completion_test.py` around lines 6 - 27, Tests test_completion_bash, test_completion_zsh, and test_completion_fish are too permissive; tighten them to assert shell-specific markers plus non-empty output. For test_completion_bash (invoking jmp ["completion","bash"]) assert exit_code == 0, len(output) > 0 and that output.lower() contains a bash completion marker such as "complete -f" or "complete -o" (or "complete -F"); for test_completion_zsh assert output contains "compdef" or "#compdef" (and non-empty); for test_completion_fish assert output contains the fish-specific "complete -c" or "complete --no-files" (and non-empty). Keep the CliRunner usage and only replace the loose "comp"/generic checks with these shell-specific assertions in the respective test functions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@python/packages/jumpstarter-cli/jumpstarter_cli/completion_test.py`:
- Around line 29-38: Update the two tests to assert the specific error/output
text so failures are for the expected reason: in test_completion_no_args() after
invoking jmp with ["completion"] check result.exit_code == 2 and assert that
result.output (or result.stderr) contains the missing-argument/usage text (e.g.
contains "Missing" or "Usage" or "SHELL") to prove it failed due to no shell
arg; in test_completion_unsupported_shell() after invoking jmp with
["completion", "powershell"] assert exit_code == 2 and that result.output
contains the unsupported-choice text and the literal "powershell" (or "Invalid
choice") so the failure is due to an unsupported shell, referencing the test
functions test_completion_no_args and test_completion_unsupported_shell and the
jmp completion invocation.
- Around line 6-27: Tests test_completion_bash, test_completion_zsh, and
test_completion_fish are too permissive; tighten them to assert shell-specific
markers plus non-empty output. For test_completion_bash (invoking jmp
["completion","bash"]) assert exit_code == 0, len(output) > 0 and that
output.lower() contains a bash completion marker such as "complete -f" or
"complete -o" (or "complete -F"); for test_completion_zsh assert output contains
"compdef" or "#compdef" (and non-empty); for test_completion_fish assert output
contains the fish-specific "complete -c" or "complete --no-files" (and
non-empty). Keep the CliRunner usage and only replace the loose "comp"/generic
checks with these shell-specific assertions in the respective test functions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d8179148-be30-4404-8190-c9f3b9d14008
📒 Files selected for processing (4)
.gitignorepython/packages/jumpstarter-cli/jumpstarter_cli/completion.pypython/packages/jumpstarter-cli/jumpstarter_cli/completion_test.pypython/packages/jumpstarter-cli/jumpstarter_cli/jmp.py
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts: # .gitignore
Summary
jmp completion bash|zsh|fishsubcommand to generate shell completion scriptsshell_completionmoduleeval "$(jmp completion bash)",eval "$(jmp completion zsh)",jmp completion fish | sourceCloses #319
Closes #35
Test plan
jmp completion bashgenerates valid bash completion scriptjmp completion zshgenerates valid zsh completion scriptjmp completion fishgenerates valid fish completion scriptjmp completionwithout args shows error (exit code 2)jmp completion powershellrejects unsupported shell (exit code 2)🤖 Generated with Claude Code
Summary by CodeRabbit