Class: Kotoshu::Cli::CompletionsCommand

Inherits:
Thor
  • Object
show all
Defined in:
lib/kotoshu/cli/completions_command.rb

Overview

Thor subcommand wired as kotoshu completions <shell>.

Emits shell completion scripts for bash, zsh, and fish, plus a languages helper that prints supported language codes one per line. The shell scripts shell out to kotoshu completions languages for dynamic language completion, so newly registered languages appear without regenerating the script.

Instance Method Summary collapse

Instance Method Details

#bashObject



178
179
180
181
182
# File 'lib/kotoshu/cli/completions_command.rb', line 178

def bash
  $stdout.puts Completions::ScriptBuilders::Bash.build(
    Completions::COMMANDS, Completions::LANGUAGE_ARGUMENT_COMMANDS
  )
end

#fishObject



192
193
194
195
196
# File 'lib/kotoshu/cli/completions_command.rb', line 192

def fish
  $stdout.puts Completions::ScriptBuilders::Fish.build(
    Completions::COMMANDS, Completions::LANGUAGE_ARGUMENT_COMMANDS
  )
end

#languagesObject



205
206
207
# File 'lib/kotoshu/cli/completions_command.rb', line 205

def languages
  Kotoshu::Language::Registry.supported_codes.each { |c| $stdout.puts c }
end

#zshObject



185
186
187
188
189
# File 'lib/kotoshu/cli/completions_command.rb', line 185

def zsh
  $stdout.puts Completions::ScriptBuilders::Zsh.build(
    Completions::COMMANDS, Completions::LANGUAGE_ARGUMENT_COMMANDS
  )
end