Class: Wavefront::Cli

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

Overview

Parent of all the CLI classes.

Direct Known Subclasses

Alerts, BatchWrite, Dashboards, Events, Sources, Ts, Write

Defined Under Namespace

Classes: Alerts, BatchWrite, Dashboards, Events, Sources, Ts, Write

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, arguments) ⇒ Cli

Returns a new instance of Cli.



26
27
28
29
30
31
32
33
34
35
# File 'lib/wavefront/cli.rb', line 26

def initialize(options, arguments)
  @options   = options
  @arguments = arguments
  @noop = options[:noop]

  if options.include?(:help) && options[:help]
    puts options
    exit 0
  end
end

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



24
25
26
# File 'lib/wavefront/cli.rb', line 24

def arguments
  @arguments
end

#noopObject

Returns the value of attribute noop.



24
25
26
# File 'lib/wavefront/cli.rb', line 24

def noop
  @noop
end

#optionsObject

Returns the value of attribute options.



24
25
26
# File 'lib/wavefront/cli.rb', line 24

def options
  @options
end

Instance Method Details

#validate_optsObject



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

def validate_opts
  #
  # There are things we need to have. If we don't have them,
  # stop the user right now. Also, if we're in debug mode, print
  # out a hash of options, which can be very useful when doing
  # actual debugging. Some classes may have to override this
  # method. The writer, for instance, uses a proxy and has no
  # token.
  #
  raise 'Please supply an API token.' unless options[:token]
  raise 'Please supply an API endpoint.' unless options[:endpoint]
end