Class: Sensu::Plugin::CLI

Inherits:
Object
  • Object
show all
Includes:
Mixlib::CLI
Defined in:
lib/sensu-plugin/cli.rb

Direct Known Subclasses

Sensu::Plugin::Check::CLI, Metric::CLI

Constant Summary collapse

@@autorun =

Behind-the-scenes stuff below. If you do something crazy like define two plugins in one script, the last one will ‘win’ in terms of what gets auto-run.

self

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = ARGV) ⇒ CLI

Returns a new instance of CLI.



14
15
16
17
# File 'lib/sensu-plugin/cli.rb', line 14

def initialize(argv = ARGV)
  super()
  self.argv = parse_options(argv)
end

Instance Attribute Details

#argvObject

Returns the value of attribute argv.



12
13
14
# File 'lib/sensu-plugin/cli.rb', line 12

def argv
  @argv
end

Class Method Details

.method_added(name) ⇒ Object



49
50
51
# File 'lib/sensu-plugin/cli.rb', line 49

def method_added(name)
  @@autorun = self if name == :run
end

Instance Method Details

#output(*args) ⇒ Object

Implementing classes should override this to produce appropriate output for their handler.



22
23
24
# File 'lib/sensu-plugin/cli.rb', line 22

def output(*args)
  puts "Sensu::Plugin::CLI: #{args}"
end

#runObject

Implementing classes must override this.



39
40
41
# File 'lib/sensu-plugin/cli.rb', line 39

def run
  unknown 'Not implemented! You should override Sensu::Plugin::CLI#run.'
end