Skip to content

Add shell completion support for bash, zsh, and fish #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 12, 2025
Merged

Conversation

hahwul
Copy link
Owner

@hahwul hahwul commented Mar 12, 2025

Implement shell completion functionality and update the README to include the new command for generating completion scripts.

@hahwul hahwul self-assigned this Mar 12, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @hahwul, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request introduces shell completion support for the deadfinder tool, covering bash, zsh, and fish. It also updates the README to reflect the new completion command. I've added a new file lib/deadfinder/completion.rb which contains the completion scripts for each shell. The CLI has been updated to include a completion command that outputs the appropriate script based on the shell specified. The gemspec file has been updated to include the new completion file. Finally, I've added tests for the new CLI command and the completion scripts.

Highlights

  • Shell Completion: Implements shell completion for bash, zsh, and fish, making the tool easier to use from the command line.
  • CLI Update: Adds a new completion command to the CLI for generating shell completion scripts.
  • README Update: The README has been updated to include the new completion command in the usage section.
  • New Completion Module: Introduces a new module DeadFinder::Completion to encapsulate the shell completion scripts.
  • Testing: Adds tests to verify the functionality of the new completion command and the generated scripts.

Changelog

Click here to see the changelog
  • README.md
    • Added deadfinder completion <SHELL> command to the usage section.
  • deadfinder.gemspec
    • Added lib/deadfinder/completion.rb to the list of files.
  • lib/deadfinder/cli.rb
    • Added require 'deadfinder/completion'.
    • Implemented the completion command to generate shell completion scripts for bash, zsh, and fish (lines 48-60).
  • lib/deadfinder/completion.rb
    • Created a new module DeadFinder::Completion with methods to generate bash, zsh, and fish completion scripts.
  • spec/dead_finder/cli_spec.rb
    • Added tests for the completion command, verifying script generation for bash, zsh, and fish, and error handling for unsupported shells (lines 53-70).
  • spec/dead_finder/completion_spec.rb
    • Created a new spec file to test the DeadFinder::Completion module, verifying the content of the generated bash, zsh, and fish completion scripts.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Did you know?

The 'shebang' line (#! /bin/bash) at the top of a bash script tells the operating system which interpreter to use to execute the script.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces shell completion support for bash, zsh, and fish, which is a useful addition to the deadfinder tool. The implementation appears to be well-structured, with separate methods for generating completion scripts for each shell. The addition of tests for the completion functionality is also commendable.

Summary of Findings

  • Error Handling for Unsupported Shells: The completion method in lib/deadfinder/cli.rb handles unsupported shells by logging an error message. While this is good, consider raising an exception or providing a more informative message to the user.
  • Missing Shell Validation: The completion method in lib/deadfinder/cli.rb doesn't validate the shell input. It might be beneficial to add a validation step to ensure that the input is one of the supported shells (bash, zsh, fish).
  • Zsh Completion Script: The zsh completion script in lib/deadfinder/completion.rb includes a commented-out compdef deadfinder line. This line is crucial for activating the completion. It should be uncommented or removed if it's not intended to be used.

Merge Readiness

The pull request is almost ready for merging. Addressing the comments regarding error handling, shell validation, and the zsh completion script would improve the quality of the code and make it more robust. I am unable to approve the pull request, and recommend that others review and approve this code before merging.

@hahwul hahwul linked an issue Mar 12, 2025 that may be closed by this pull request
Copy link

codecov bot commented Mar 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@hahwul hahwul merged commit 9db3e24 into main Mar 12, 2025
5 checks passed
@hahwul hahwul deleted the features/issue-50 branch March 12, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add shell completions
1 participant