1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

fixes issues with logging in with username and password. plus better output

This commit is contained in:
bmizerany 2008-07-16 15:50:54 -07:00
parent df862899e8
commit 91881489d5

View file

@ -3,18 +3,19 @@
$:.unshift File.dirname(__FILE__) + "/../lib" $:.unshift File.dirname(__FILE__) + "/../lib"
require 'rest_client' require 'rest_client'
def usage def usage(why = nil)
puts "failed for reason: #{why}" if why
puts "usage: restclient url [username] [password]" puts "usage: restclient url [username] [password]"
exit(1) exit(1)
end end
@url = ARGV.first || 'http://localhost:4567' @url = ARGV.shift || 'http://localhost:4567'
usage unless @url =~ /^https?/ usage("invalid url '#{@url}") unless @url =~ /^https?/
usage unless ARGV.size < 3 usage("to few args") unless ARGV.size < 3
def r def r
@r ||= RestClient::Resource.new(*[@url, ARGV]) @r ||= RestClient::Resource.new(@url, *ARGV)
end end
r # force rc to load r # force rc to load