lib/twurl/cli.rb in twurl-0.6.2 vs lib/twurl/cli.rb in twurl-0.6.3
- old
+ new
@@ -37,10 +37,11 @@
arguments = args.dup
Twurl.options = Options.new
Twurl.options.trace = false
Twurl.options.data = {}
+ Twurl.options.headers = {}
option_parser = OptionParser.new do |o|
o.extend AvailableOptions
o.banner = "Usage: twurl authorize -u username -p password --consumer-key HQsAGcVm5MQT3n6j7qVJw --consumer-secret asdfasd223sd2\n" +
@@ -62,15 +63,17 @@
end
o.section "Common options:" do
trace
data
+ headers
host
quiet
disable_ssl
request_method
help
+ version
end
end
arguments = option_parser.parse!(args)
Twurl.options.command = extract_command!(arguments)
@@ -188,10 +191,17 @@
options.data[key] = value
end
end
end
+ def headers
+ on('-A', '--header [header]', 'Adds the specified header to the request to the HTTP server.') do |header|
+ key, value = header.split(': ')
+ options.headers[key] = value
+ end
+ end
+
def host
on('-H', '--host [host]', 'Specify host to make requests to (default: api.twitter.com)') do |host|
options.host = host
end
end
@@ -215,9 +225,16 @@
end
def help
on_tail("-h", "--help", "Show this message") do
CLI.puts self
+ exit
+ end
+ end
+
+ def version
+ on_tail("-v", "--version", "Show version") do
+ CLI.puts Version
exit
end
end
end
end