Class: Dry::CLI::Completion::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/linear/cli.rb

Overview

Monkeypatching the Generator just to add our ‘lc’ alias :(

Instance Method Summary collapse

Instance Method Details

#call(shell:, include_aliases: false, out: StringIO.new) ⇒ Object

rubocop:disable Metrics/MethodLength

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/linear/cli.rb', line 15

def call(shell:, include_aliases: false, out: StringIO.new) # rubocop:disable Metrics/MethodLength
  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:)
  ).script
  # Here is the only change in our monkeypatch! Lame, right?
  out.puts 'complete -F _linear-cli_completions lc'
  out.string
end