Class: Dry::CLI::Completion::Generator
- Inherits:
-
Object
- Object
- Dry::CLI::Completion::Generator
- Defined in:
- lib/dry/cli/completion/generator.rb
Instance Method Summary collapse
- #call(shell:, include_aliases: false, out: StringIO.new) ⇒ Object
-
#initialize(registry, program_name: nil) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
Instance Method Details
#call(shell:, include_aliases: false, out: StringIO.new) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dry/cli/completion/generator.rb', line 16 def call(shell:, include_aliases: false, out: StringIO.new) raise ArgumentError, "Unknown shell" unless SUPPORTED_SHELLS.include?(shell) if shell == ZSH out.puts "# enable bash completion support, see https://github.com/dannyben/completely#completions-in-zsh" out.puts "autoload -Uz +X compinit && compinit" out.puts "autoload -Uz +X bashcompinit && bashcompinit" end out.puts Completely::Completions.new( Input.new(@registry, @program_name).call(include_aliases: include_aliases) ).script out.string end |