diff --git a/Manifest b/Manifest
index 6e00ba9..de28556 100644
--- a/Manifest
+++ b/Manifest
@@ -7,7 +7,6 @@ examples/rubyurl.rb
examples/twitter.rb
examples/whoismyrep.rb
History
-httparty.gemspec
lib/core_extensions.rb
lib/httparty/exceptions.rb
lib/httparty/request.rb
diff --git a/README b/README
index 7e58752..cf5291e 100644
--- a/README
+++ b/README
@@ -15,6 +15,17 @@ Makes http fun again!
See http://github.com/jnunemaker/httparty/tree/master/examples
+== COMMAND LINE INTERFACE
+
+httparty also includes the executable httparty which can be
+used to query web services and examine the resulting output. By default
+it will output the response as a pretty-printed Ruby object (useful for
+grokking the structure of output). This can also be overridden to output
+formatted XML or JSON. Execute httparty --help for all the
+options. Below is an example of how easy it is.
+
+ httparty "http://twitter.com/statuses/public_timeline.json" -f json
+
== REQUIREMENTS:
* JSON ~> 1.1
diff --git a/bin/httparty b/bin/httparty
index d55e90f..fb5b0b7 100755
--- a/bin/httparty
+++ b/bin/httparty
@@ -80,18 +80,24 @@ module REXML
end
end
-response = HTTParty.send(opts[:action], ARGV.first, opts.merge(:format => :plain))
-
-if opts[:pretty_print]
- pp response
+if opts[:pretty_print] || opts[:format].nil?
+ pp HTTParty.send(opts[:action], ARGV.first, opts)
else
- case opts[:format]
- when :json
- puts JSON.pretty_generate(JSON.parse(response))
- when :xml
- REXML::Document.new(response).write(STDOUT, 2)
- puts
+ print_format = opts[:format]
+ opts.merge!(:format => :plain) if opts[:format]
+ response = HTTParty.send(opts[:action], ARGV.first, opts)
+
+ if print_format.nil?
+ pp response
else
- puts response
+ case print_format
+ when :json
+ puts JSON.pretty_generate(JSON.parse(response))
+ when :xml
+ REXML::Document.new(response).write(STDOUT, 2)
+ puts
+ else
+ puts response
+ end
end
-end
+end
\ No newline at end of file