Skip to content

feat: add shell completion support#116

Open
y-cg wants to merge 4 commits intojnsahaj:mainfrom
y-cg:shell-completion
Open

feat: add shell completion support#116
y-cg wants to merge 4 commits intojnsahaj:mainfrom
y-cg:shell-completion

Conversation

@y-cg
Copy link
Copy Markdown

@y-cg y-cg commented Jan 18, 2026

This PR adds shell completion support for multiple shells. Close #109.

Summary by CodeRabbit

  • New Features

    • Shell completion added for Bash, Zsh, Fish, PowerShell, and Elvish to enable tab completion for commands and options.
  • Documentation

    • README updated with a Shell Completion guide showing how to enable and persist tab completion.
  • Packaging

    • Installers now include/install shell completion scripts so completions are available after installation.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

A new shell completion feature is introduced using the clap_complete crate. Users can run lumen completion <shell> to generate completion scripts for bash, zsh, fish, powershell, and elvish. Implementation includes CLI schema updates, a new completion module, README docs, and integration in the main entry point.

Changes

Cohort / File(s) Summary
Dependency Management
Cargo.toml
Added clap_complete = "4.4" to enable generating shell completion scripts.
CLI Schema & Subcommand
src/config/cli.rs
Added CompletionShell enum (Bash, Zsh, Fish, PowerShell, Elvish) and a new Completion { shell: CompletionShell } subcommand. Added ValueHint annotations to several CLI fields (e.g., config, api_key, model, reference, query, pr, file, theme).
Completion Module
src/command/completion.rs, src/command/mod.rs
New completion module with pub fn generate_completions(shell: CompletionShell) mapping CompletionShell to clap_complete::Shell and emitting completion scripts to stdout. Module exported via pub mod completion;.
Application Routing
src/main.rs
Added early-return handling for the Completion subcommand: call generate_completions() and return Ok(()) before normal config/build/command dispatch.
Documentation
README.md
Added "Shell Completion" section and TOC entry describing how to generate and persist completion scripts for Bash and Zsh.
Nix Packaging
flake.nix
Reworked outputs to per-system structure via flake-utils.lib.eachDefaultSystem, added per-system package build (with postInstall installing completion scripts for bash/fish/zsh), and adjusted devShells packaging layout.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as Clap CLI Parser
    participant Main as src/main.rs
    participant CompMod as completion module
    participant Stdout as Shell Stdout

    User->>CLI: lumen completion bash
    CLI->>Main: Route Completion{shell: Bash}
    Main->>CompMod: generate_completions(Bash)
    CompMod->>CompMod: Build CLI schema (Cli::command())
    CompMod->>CompMod: Map Bash → clap_complete::Shell
    CompMod->>Stdout: Generate & emit completion script
    Stdout->>User: Bash completion script
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 With whiskers aquiver and a joyful bound,
Shell completions at last are found!
Bash, Zsh, Fish—tab completion's dream,
Lumen's completionist golden beam ✨
Scripts hop to stdout, our magic complete!

🚥 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 pull request title 'feat: add shell completion support' directly and clearly summarizes the main change, matching the primary objective of adding shell completion functionality.
Linked Issues check ✅ Passed The pull request successfully implements the requirements from issue #109: it adds a lumen completion <shell> generator supporting bash, zsh, fish, powershell, and elvish shells.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing shell completion support. The flake.nix restructuring is minimal and only includes logic to install completions during package build.

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


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.

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.

Provide official shell completions (bash/zsh/fish)

1 participant