Class: Legion::CLI::Completion

Inherits:
Thor
  • Object
show all
Defined in:
lib/legion/cli/completion_command.rb

Constant Summary collapse

COMPLETION_DIR =
File.expand_path('../../../completions', __dir__)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/legion/cli/completion_command.rb', line 6

def self.exit_on_failure?
  true
end

Instance Method Details

#bashObject



22
23
24
# File 'lib/legion/cli/completion_command.rb', line 22

def bash
  puts File.read(File.join(COMPLETION_DIR, 'legion.bash'))
end

#installObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/legion/cli/completion_command.rb', line 42

def install
  shell = detect_shell
  out = Output::Formatter.new(color: true, json: false)

  out.header('Legion Shell Completion')
  out.spacer

  case shell
  when 'zsh'
    print_zsh_instructions(out)
  when 'bash'
    print_bash_instructions(out)
  else
    print_bash_instructions(out)
    out.spacer
    print_zsh_instructions(out)
  end
end

#zshObject



37
38
39
# File 'lib/legion/cli/completion_command.rb', line 37

def zsh
  puts File.read(File.join(COMPLETION_DIR, '_legion'))
end