Class: SaltHiera::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/salt_hiera/CLI.rb

Class Method Summary collapse

Class Method Details

.executeObject



37
38
39
40
41
42
# File 'lib/salt_hiera/CLI.rb', line 37

def self.execute

  salthiera = SaltHiera.new :config_file => @@opts[:config], :params => @@opts[:params]
  puts salthiera.to_yaml

end

.helpObject



6
7
8
9
10
# File 'lib/salt_hiera/CLI.rb', line 6

def self.help
  puts "Usage: salthiera [ -c configfile ] key1=value1 key2=value2 key3=value3 ..."
  puts "  -c : specify a configfile to use"
  exit 0
end

.parseObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/salt_hiera/CLI.rb', line 12

def self.parse

  params = {}
  config_file = "/etc/salthiera.yaml"

  while arg = ARGV.shift do
    case arg
    when "--help"
      self.help
    when "-c"
      config_file = ARGV.shift
    else
      key, value = arg.split("=", 2)
      if value
        params[key] = value
      else
        self.help
      end
    end
  end

  @@opts = { :config => config_file, :params => params }

end