Class: Tabry::OptionsFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/tabry/options_finder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ OptionsFinder

Returns a new instance of OptionsFinder.



14
15
16
# File 'lib/tabry/options_finder.rb', line 14

def initialize(result)
  @result = result
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



7
8
9
# File 'lib/tabry/options_finder.rb', line 7

def result
  @result
end

Class Method Details

.options(result, token) ⇒ Object

Returns an array of options



10
11
12
# File 'lib/tabry/options_finder.rb', line 10

def self.options(result, token)
  new(result).options(token)
end

Instance Method Details

#options(token) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tabry/options_finder.rb', line 18

def options(token)
  # Bit of a hack: send this down to autocomplete shell commands
  # TODO: set this only in ShellOption -- would require passing state down on thru
  ENV["TABRY_AUTOCOMPLETE_STATE"] = {
    cmd: result.config.cmd,
    flags: result.state.flags,
    args: result.state.args,
    current_flag: result.state.current_flag
  }.to_json

  send(:"options_#{state.mode}", token || "")
end