Skip to content

Add completions for bash and zsh#2853

Merged
naomijub merged 18 commits intomainfrom
bash-autocomplete
Dec 4, 2025
Merged

Add completions for bash and zsh#2853
naomijub merged 18 commits intomainfrom
bash-autocomplete

Conversation

@smyrick
Copy link
Member

@smyrick smyrick commented Nov 11, 2025

This pull request introduces shell completion support for Rover, allowing users to generate bash and zsh completion scripts via new commands. It adds the necessary implementation, updates dependencies, and provides integration tests and documentation for Homebrew formula updates. These changes improve the user experience by enabling tab completion for Rover commands in bash and zsh shells.

This was created with Cursor AI. I am not a Rust expert but the code seems reasonable to me. Please provide more feedback that necessary.

Shell Completion Feature

  • Added new rover completion bash and rover completion zsh commands, which generate shell completion scripts for bash and zsh, respectively, using the clap_complete crate. [1] [2] [3] [4]
  • Updated the CLI logic to skip update checks for completion commands and properly dispatch to the new completion handlers. [1] [2]

Dependency Updates

  • Added clap_complete as a dependency in both the main and workspace sections of Cargo.toml to support shell completion generation. [1] [2]

Testing

  • Added integration tests to verify that the rover completion bash and rover completion zsh commands generate the expected completion scripts. [1] [2]

Documentation

  • Added a new HOMEBREW_FORMULA_UPDATE.md file detailing the changes required to the Homebrew formula for automatic installation of completion scripts.

Changelog

  • Updated CHANGELOG.md to document the addition of shell completion support for bash and zsh.

@smyrick smyrick requested a review from a team as a code owner November 11, 2025 23:48
@smyrick smyrick requested a review from a team November 11, 2025 23:48
@apollo-librarian
Copy link
Contributor

apollo-librarian bot commented Nov 11, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

1 new, 2 changed, 0 removed
+ (developer-tools)/rover/commands/completion.mdx
* (developer-tools)/rover/getting-started.mdx
* (developer-tools)/rover/_sidebar.yaml

Build ID: fe56d79e2e787cff8f45a6ec
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/fe56d79e2e787cff8f45a6ec

@smyrick smyrick requested a review from a team as a code owner November 11, 2025 23:54
}

#[test]
fn it_generates_zsh_completion() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Kinda hard to test this for real automatically—have you manually tested with both bash and zsh?

Copy link
Member Author

Choose a reason for hiding this comment

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

Screenshot 2025-11-12 at 9 49 45 AM

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the test to at least validate the output is valid bash and zsh scripts.

@smyrick
Copy link
Member Author

smyrick commented Nov 12, 2025

For updating later:

Homebrew Formula Update for Shell Completions

This document describes the changes needed to the Homebrew formula to automatically install bash and zsh completion scripts when Rover is installed via Homebrew.

Formula Location

The Rover Homebrew formula is maintained at:
https://github.com/Homebrew/homebrew-core/blob/master/Formula/r/rover.rb

Required Changes

Update the install method in the formula to generate and install completion scripts:

def install
  # Ensure that the `openssl` crate picks up the intended library.
  ENV["OPENSSL_DIR"] = Formula["openssl@3"].opt_prefix
  ENV["OPENSSL_NO_VENDOR"] = "1"

  system "cargo", "install", *std_cargo_args

  # Generate and install bash completion
  bash_completion.install Utils.safe_popen_read(bin/"rover", "completion", "bash")

  # Generate and install zsh completion
  zsh_completion.install Utils.safe_popen_read(bin/"rover", "completion", "zsh")
end

Explanation

  • bash_completion.install installs the bash completion script to share/bash-completion/completions/rover
  • zsh_completion.install installs the zsh completion script to share/zsh/site-functions/_rover
  • Utils.safe_popen_read executes the rover completion command and captures its output
  • The completion scripts are generated dynamically using the rover completion subcommand

Testing

After updating the formula:

  1. Install Rover via Homebrew: brew install rover
  2. Verify bash completion is installed: ls $(brew --prefix)/share/bash-completion/completions/rover
  3. Verify zsh completion is installed: ls $(brew --prefix)/share/zsh/site-functions/_rover
  4. Test completion in your shell (may require restarting the shell or sourcing completion files)

Notes

  • Bash completion requires bash-completion to be installed (usually via brew install bash-completion@2)
  • Zsh completion should work automatically if zsh is configured properly
  • Users may need to restart their shell or source completion files for completions to take effect

@naomijub naomijub requested a review from mabuyo November 17, 2025 16:52
@mabuyo mabuyo requested review from the-gigi-apollo and removed request for mabuyo November 17, 2025 16:59
@naomijub
Copy link
Contributor

@smyrick there are conflicts on Cargo.lock, can you update?

@smyrick smyrick force-pushed the bash-autocomplete branch 2 times, most recently from 263653e to 09c6f73 Compare November 26, 2025 18:33
@smyrick
Copy link
Member Author

smyrick commented Nov 26, 2025

@naomijub I am not sure why the other jobs are failing now. It looks like they are not setup for NodeJS? Is that a separate issue?

It looks like other PRs have the same issue: #2893

Copy link
Contributor

@naomijub naomijub left a comment

Choose a reason for hiding this comment

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

Docs review approved

@naomijub naomijub added this pull request to the merge queue Dec 4, 2025
Merged via the queue into main with commit 5a45b05 Dec 4, 2025
45 of 47 checks passed
@naomijub naomijub deleted the bash-autocomplete branch December 4, 2025 23:08
@smyrick
Copy link
Member Author

smyrick commented Dec 18, 2025

Validated and working with Homebrew!
Screenshot 2025-12-18 at 9 16 21 AM

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.

4 participants