Skip to content

feat: add jmp completion command for bash/zsh/fish#334

Merged
mangelajo merged 6 commits intojumpstarter-dev:mainfrom
raballew:004-shell-completion
Mar 18, 2026
Merged

feat: add jmp completion command for bash/zsh/fish#334
mangelajo merged 6 commits intojumpstarter-dev:mainfrom
raballew:004-shell-completion

Conversation

@raballew
Copy link
Contributor

@raballew raballew commented Mar 17, 2026

Summary

  • Add jmp completion bash|zsh|fish subcommand to generate shell completion scripts
  • Uses Click's built-in shell_completion module
  • Usage: eval "$(jmp completion bash)", eval "$(jmp completion zsh)", jmp completion fish | source

Closes #319
Closes #35

Test plan

  • jmp completion bash generates valid bash completion script
  • jmp completion zsh generates valid zsh completion script
  • jmp completion fish generates valid fish completion script
  • jmp completion without args shows error (exit code 2)
  • jmp completion powershell rejects unsupported shell (exit code 2)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a CLI command to generate shell completion scripts for bash, zsh, and fish to simplify tab-completion setup.
  • Tests
    • Added tests verifying completion output for supported shells, missing-argument handling, and unsupported-shell behavior.
  • Chores
    • Expanded .gitignore to ignore additional local tooling files and directories (.specify/, .envrc, specs/).

raballew and others added 3 commits March 17, 2026 18:31
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>
@netlify
Copy link

netlify bot commented Mar 17, 2026

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit a17e3c9
🔍 Latest deploy log https://app.netlify.com/projects/jumpstarter-docs/deploys/69ba6466ccb97700082548c8
😎 Deploy Preview https://deploy-preview-334--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef8197cd-a833-462e-9807-dfb15a01349b

📥 Commits

Reviewing files that changed from the base of the PR and between 8d45d8c and a17e3c9.

📒 Files selected for processing (1)
  • .gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • .gitignore

📝 Walkthrough

Walkthrough

Adds a new completion subcommand to the jmp CLI that emits shell completion scripts for bash, zsh, and fish; registers the command with the jmp Click group, adds unit tests for completion behavior, and updates .gitignore to ignore local tooling files (.specify/, .envrc, specs/).

Changes

Cohort / File(s) Summary
Shell completion command
python/packages/jumpstarter-cli/jumpstarter_cli/completion.py, python/packages/jumpstarter-cli/jumpstarter_cli/jmp.py
Adds a Click completion command accepting a shell arg (bash
Completion tests
python/packages/jumpstarter-cli/jumpstarter_cli/completion_test.py
New tests using Click's CliRunner for bash, zsh, fish, missing-arg, and unsupported-shell scenarios; validates exit codes and key output markers.
Ignored local tooling
.gitignore
Adds .specify/, .envrc, and specs/ to the Local tooling ignore list.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped to the shell with a tiny twitch,
Click and script in my hopping pitch.
Bash, zsh, fish — the flowers align,
My carrots autocomplete just fine.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add jmp completion command for bash/zsh/fish' accurately and concisely summarizes the main change: adding a new completion subcommand supporting multiple shells.
Linked Issues check ✅ Passed The PR implementation meets the primary requirements from both linked issues: it adds a native 'jmp completion' command supporting bash, zsh, and fish, eliminating the 'No such command' error and providing an alternative to manual environment variable usage.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the completion command feature. The .gitignore update is a minor supporting change. No unrelated or out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@raballew raballew marked this pull request as ready for review March 17, 2026 21:07
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between ec11dc4 and 001553d.

📒 Files selected for processing (4)
  • .gitignore
  • python/packages/jumpstarter-cli/jumpstarter_cli/completion.py
  • python/packages/jumpstarter-cli/jumpstarter_cli/completion_test.py
  • python/packages/jumpstarter-cli/jumpstarter_cli/jmp.py

raballew and others added 2 commits March 18, 2026 00:07
@mangelajo mangelajo merged commit 1bb7822 into jumpstarter-dev:main Mar 18, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No shell completion support RFE: terminal autocomplete for jumpstarter

2 participants