0.0
No release in over 3 years
Generate shell completions for Thor CLIs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

Runtime

 Project Readme

thor-completion

Warning

Most of this project was generated by Claude Code, because I needed it for another project. It works, but it might not be perfect.

Tests Gem Gem MIT License

Generate shell completions for Thor CLIs.

Installation

gem install thor-completion

Or add the following line to your project's Gemfile:

gem "thor-completion"

Usage

On your Thor CLI, add a command to generate the completion script:

require "thor/completion"

class MyCLI < Thor
  desc "completion", "Generate shell completion script"
  option :shell,
         type: :string,
         required: true,
         enum: %w[bash zsh powershell fish]
  def completion
    puts Thor::Completion.generate(
      name: "mycli",
      description: "This is mycli",
      version: "1.2.3",
      cli: self.class,
      shell: options.shell
    )
  end
end

Then users can call mycli completion --shell <SHELL>. Loading the generated script into their shell enables tab completion for your CLI.

Supported Shells

  • Bash
  • Zsh
  • PowerShell
  • Fish

Maintainer

Contributors

Contributing

For more details about how to contribute, please read https://github.com/fnando/thor-completion/blob/main/CONTRIBUTING.md.

License

The gem is available as open source under the terms of the MIT License. A copy of the license can be found at https://github.com/fnando/thor-completion/blob/main/LICENSE.md.

Code of Conduct

Everyone interacting in the thor-completion project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.