Class: Jerakia::CLI

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

Instance Method Summary collapse

Instance Method Details

#lookup(key) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/jerakia/cli.rb', line 69

def lookup(key)

  case true
  when options[:verbose]
    loglevel = "verbose"
    logfile  = STDOUT
  when options[:debug]
    loglevel = "debug"
    logfile  = STDOUT
  else
    logfile = nil
    loglevel = options[:log_level]
  end

  jac = Jerakia.new({
    :config   => options[:config],
    :logfile  => logfile,
    :loglevel => loglevel,
  })
  req = Jerakia::Request.new(
    :key           => key,
    :namespace     => options[:namespace].split(/::/),
    :policy        => options[:policy].to_sym,
    :lookup_type   => options[:type].to_sym,
    :merge         => options[:merge_type].to_sym,
    :metadata      => options[:metadata] || {},
    :scope         => options[:scope].to_sym,
    :scope_options => options[:scope_options],
    :use_schema    => options[:schema],
  )

  answer = jac.lookup(req)
  case options[:output]
  when 'json'
    puts answer.payload.to_json
  when 'yaml'
    puts answer.payload.to_yaml
  end
end

#versionObject



110
111
112
# File 'lib/jerakia/cli.rb', line 110

def version
  puts Jerakia::VERSION
end