Skip to content

Commit

Permalink
Bumping to version 0.0.5
Browse files Browse the repository at this point in the history
Better CLI parsing error handling
  • Loading branch information
dbroeglin committed Mar 21, 2012
1 parent c0a888b commit 4b9bb60
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -29,7 +29,7 @@ Features
Usage and documentation
-----------------------

NagiosCheck is a module. To use it simply include it in a class and declare
NagiosCheck is a module. To use it, simply include it in a class and declare
how the check should behave:

``` ruby
Expand Down
15 changes: 12 additions & 3 deletions lib/nagios_check.rb
Expand Up @@ -17,9 +17,9 @@ def prepare

def run
prepare
parse_options
return_val, status = 3, "UNKNOWN"
begin
parse_options
if @timeout
check_with_timeout
else
Expand All @@ -28,6 +28,8 @@ def run
return_val, status = finish
rescue Timeout::Error
store_message "TIMEOUT after #{@timeout}s"
rescue OptionParser::InvalidArgument, NagiosCheck::MissingOption => e
store_message "CLI ERROR: #{e}"
rescue => e
store_message "INTERNAL ERROR: #{e}"
end
Expand Down Expand Up @@ -160,6 +162,13 @@ def check_with_timeout
Timeout.timeout(@timeout) { check }
end

class MissingOption < StandardError; end
class MissingOption < StandardError; end
class MissingOption < StandardError;
def initialize(name)
@name = name
end

def to_s
"missing option: '#{@name}'"
end
end
end
2 changes: 1 addition & 1 deletion lib/nagios_check/version.rb
@@ -1,3 +1,3 @@
module NagiosCheck
VERSION = "0.0.4"
VERSION = "0.0.5"
end

0 comments on commit 4b9bb60

Please sign in to comment.