Permalink
Browse files

Adding -r argument to executable to fail if response code >= 400

Failing if the response code is >= 400 is very helpful in for example
continuous integration to check after deployment that certain pages still
work.
  • Loading branch information...
1 parent 8fe9fda commit d0a88d79b4c0a9c05181ff3f876a79b957a52691 @flomotlik flomotlik committed Dec 8, 2011
Showing with 5 additions and 0 deletions.
  1. +5 −0 bin/httparty
View
@@ -54,6 +54,10 @@ OptionParser.new do |o|
opts[:basic_auth] = { :username => user, :password => password }
end
+ o.on("-r", "--response-code", "Command fails if response code >= 400") do
+ opts[:response_code] = true
+ end
+
o.on("-h", "--help", "Show help documentation") do |h|
puts o
exit
@@ -106,3 +110,4 @@ else
puts response
end
end
+exit false if opts[:response_code] && response.code >= 400

0 comments on commit d0a88d7

Please sign in to comment.