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.
Generate shell completions for Thor CLIs.
Installation
gem install thor-completionOr 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
endThen 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.