From 91881489d5bc461b986b121b1ed8bba46994a6ec Mon Sep 17 00:00:00 2001 From: bmizerany Date: Wed, 16 Jul 2008 15:50:54 -0700 Subject: [PATCH] fixes issues with logging in with username and password. plus better output --- bin/restclient | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/restclient b/bin/restclient index 94f9910..2cf02e4 100755 --- a/bin/restclient +++ b/bin/restclient @@ -3,18 +3,19 @@ $:.unshift File.dirname(__FILE__) + "/../lib" require 'rest_client' -def usage +def usage(why = nil) + puts "failed for reason: #{why}" if why puts "usage: restclient url [username] [password]" exit(1) end -@url = ARGV.first || 'http://localhost:4567' +@url = ARGV.shift || 'http://localhost:4567' -usage unless @url =~ /^https?/ -usage unless ARGV.size < 3 +usage("invalid url '#{@url}") unless @url =~ /^https?/ +usage("to few args") unless ARGV.size < 3 def r - @r ||= RestClient::Resource.new(*[@url, ARGV]) + @r ||= RestClient::Resource.new(@url, *ARGV) end r # force rc to load