Class: Tomo::CLI::Completions

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(literal: false, stdout: $stdout) ⇒ Completions

Returns a new instance of Completions.



14
15
16
17
# File 'lib/tomo/cli/completions.rb', line 14

def initialize(literal: false, stdout: $stdout)
  @literal = literal
  @stdout = stdout
end

Class Method Details

.activateObject



6
7
8
# File 'lib/tomo/cli/completions.rb', line 6

def self.activate
  @active = true
end

.active?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/tomo/cli/completions.rb', line 10

def self.active?
  defined?(@active) && @active
end

Instance Method Details



19
20
21
22
23
24
# File 'lib/tomo/cli/completions.rb', line 19

def print_completions_and_exit(rules, *args, state:)
  completions = completions_for(rules, *args, state)
  words = completions.map { |c| bash_word_for(c, args.last) }
  Tomo.logger.info(words.join("\n")) unless words.empty?
  CLI.exit
end