Class: DownRightNow::Util::CommandLine

Inherits:
Object
  • Object
show all
Defined in:
lib/downrightnow/util/command_line.rb

Instance Method Summary collapse

Instance Method Details

#execObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/downrightnow/util/command_line.rb', line 8

def exec
	begin
	  opts = Trollop::options do
	    version "DownRightNow (tm) unofficial ruby utility #{::DownRightNow.version}  (c) 2011 Barry Allard"
	    banner <<-EOS
	DownRightNow (tm) unofficial ruby utility #{::DownRightNow.version}  (c) 2011 Barry Allard

	    EOS
	    opt :verbose,         "Verbose display", :default => false
	    opt :error_on_outage, "Return error exit code if any outage", :default => false
	  end
	  drn = DownRightNow.new
	  puts drn.to_s opts[:verbose]
	  exit 1 if opts[:error_on_outage] && drn.any_outages?
	rescue => e
#	  puts e
#	  exit 1
    raise e
	end
end