marcel/twurl — pull request #31 by esbie (2013-07-09 22:25:10+00:00)
Title: 3 Twurl::CLI modifications for improved usability

1. Unfriendly starting exception
The twurl command when invoked by itself throws an error
```
$ twurl
/Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:1478:in `initialize': HTTP request path is empty (ArgumentError)
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:1596:in `initialize'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/oauth_client.rb:77:in `new'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/oauth_client.rb:77:in `perform_request_from_options'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/request_controller.rb:13:in `perform_request'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/request_controller.rb:9:in `dispatch'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/abstract_command_controller.rb:7:in `dispatch'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/cli.rb:31:in `dispatch'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/cli.rb:14:in `run'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/twurl:4
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/bin/twurl:19:in `load'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/bin/twurl:19
```
This pull request shows the --help menu instead.

2. Unfriendly host with protocol exception
When accidentally including the protocol as part of the host, one receives the following error:
```
$ twurl -H https://other-api.example.com /0/test
/Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError)
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:560:in `open'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:560:in `connect'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/timeout.rb:67:in `timeout'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/timeout.rb:101:in `timeout'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:560:in `connect'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:553:in `do_start'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:542:in `start'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:1035:in `request'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/oauth_client.rb:80:in `perform_request_from_options'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/request_controller.rb:13:in `perform_request'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/request_controller.rb:9:in `dispatch'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/abstract_command_controller.rb:7:in `dispatch'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/cli.rb:31:in `dispatch'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/../lib/twurl/cli.rb:14:in `run'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/twurl-0.8.1/bin/twurl:4
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/bin/twurl:19:in `load'
from /Users/sarahbrown/.rbenv/versions/ree-1.8.7-2011.03/bin/twurl:19
```
It's hard to understand what is wrong with the host from this message. This is an easy mistake to make when the user is familiar with curl, where the protocol is required. This request removes any extra protocol from the host.

3. Encoding url parameters
Parameters such as "?start_time=2013-01-06T07:59:00Z" should be encoded as "?start_time=2013-01-06T07%3A59%3A00Z"