Class: Facter::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/framework/core/options.rb

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



14
15
16
# File 'lib/facter/framework/core/options.rb', line 14

def [](key)
  OptionStore.send(key.to_sym)
end

.[]=(key, value) ⇒ Object



18
19
20
# File 'lib/facter/framework/core/options.rb', line 18

def []=(key, value)
  OptionStore.send("#{key}=".to_sym, value)
end

.cli?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/facter/framework/core/options.rb', line 6

def cli?
  OptionStore.cli
end

.custom_dirObject



26
27
28
# File 'lib/facter/framework/core/options.rb', line 26

def custom_dir
  [OptionStore.custom_dir].flatten
end

.custom_dir?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/facter/framework/core/options.rb', line 22

def custom_dir?
  OptionStore.custom_dir && OptionStore.custom_facts
end

.external_dirObject



34
35
36
# File 'lib/facter/framework/core/options.rb', line 34

def external_dir
  OptionStore.external_dir
end

.external_dir?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/facter/framework/core/options.rb', line 30

def external_dir?
  OptionStore.external_dir && OptionStore.external_facts
end

.getObject



10
11
12
# File 'lib/facter/framework/core/options.rb', line 10

def get
  OptionStore.all
end

.initObject



38
39
40
41
42
# File 'lib/facter/framework/core/options.rb', line 38

def init
  OptionStore.cli = false
  ConfigFileOptions.init
  store(ConfigFileOptions.get)
end

.init_from_cli(cli_options = {}, user_query = nil) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/facter/framework/core/options.rb', line 44

def init_from_cli(cli_options = {}, user_query = nil)
  Facter::OptionStore.cli = true
  Facter::OptionStore.show_legacy = false
  Facter::OptionStore.user_query = user_query
  Facter::OptionStore.trace = cli_options[:trace]
  OptionStore.set(:config, cli_options[:config])
  ConfigFileOptions.init(cli_options[:config])
  store(ConfigFileOptions.get)
  store(cli_options)

  Facter::OptionsValidator.validate_configs(get)
end

.store(options) ⇒ Object



57
58
59
60
61
62
# File 'lib/facter/framework/core/options.rb', line 57

def store(options)
  options.each do |key, value|
    value = '' if key == 'log_level' && value == 'log_level'
    OptionStore.set(key, value)
  end
end