Class: Wavefront::Cli

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

Direct Known Subclasses

Alerts, Events, Ts

Defined Under Namespace

Classes: Alerts, Events, Ts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, arguments) ⇒ Cli

Returns a new instance of Cli.



24
25
26
27
28
29
30
31
32
# File 'lib/wavefront/cli.rb', line 24

def initialize(options, arguments)
  @options   = options
  @arguments = arguments

  if @options[:help]
    puts @options
    exit 0
  end
end

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



22
23
24
# File 'lib/wavefront/cli.rb', line 22

def arguments
  @arguments
end

#optionsObject

Returns the value of attribute options.



22
23
24
# File 'lib/wavefront/cli.rb', line 22

def options
  @options
end

Instance Method Details

#load_profileObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/wavefront/cli.rb', line 34

def load_profile
  cf = Pathname.new(options[:config])
  pf = options[:profile]

  if cf.exist?
    raw = IniFile.load(cf)
    profile = raw[pf]

    unless profile.empty?
      puts "using #{pf} profile from #{cf}" if options[:debug]
      return profile.inject({}){|x, (k, v)| x[k.to_sym] = v; x }
    end

  else
    puts "no config file at '#{cf}': using options" if options[:debug]
  end
end