From 0b929e8b8521201ba2aff0480d152f1d44ee164b Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Thu, 15 Nov 2012 15:46:25 +0000 Subject: Added --test flag --- bin/custodian-enqueue | 6 ++++++ lib/custodian/parser.rb | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/bin/custodian-enqueue b/bin/custodian-enqueue index 5f8c5fa..fefed04 100755 --- a/bin/custodian-enqueue +++ b/bin/custodian-enqueue @@ -8,6 +8,7 @@ # [ -m | --manual] # [ -f | --file FILE] # [ -d | --dump ] +# [ | --test ] # [ -t | --timeout N ] # # OPTIONS @@ -18,6 +19,8 @@ # # -d, --dump Dump the generated JSON to the console; don't insert in the queue. # +# --test Test the parsing of the given file, alert on errors. +# # -f, --file FILE Parse the given configuration file. # # -t, --timeout N Specify the timeout period for the tests. @@ -64,6 +67,7 @@ if __FILE__ == $0 then begin opts = GetoptLong.new( [ "--dump", "-d", GetoptLong::NO_ARGUMENT ], + [ "--test", GetoptLong::NO_ARGUMENT ], [ "--file", "-f", GetoptLong::REQUIRED_ARGUMENT ], [ "--help", "-h", GetoptLong::NO_ARGUMENT ], [ "--manual","-m", GetoptLong::NO_ARGUMENT ], @@ -73,6 +77,8 @@ if __FILE__ == $0 then case opt when "--dump": ENV["DUMP"] = "1" + when "--test": + ENV["TEST"] = "1" when "--file": ENV["FILE"] = arg when "--timeout": diff --git a/lib/custodian/parser.rb b/lib/custodian/parser.rb index 29c69f6..6407621 100755 --- a/lib/custodian/parser.rb +++ b/lib/custodian/parser.rb @@ -424,6 +424,11 @@ class MonitorConfig end + # + # Just testing syntax? At this point we're done + # + next if ( ENV['TEST'] ) + # # We've now parsed the line. Either output the JSON to the console # or add to the queue. -- cgit v1.2.1