lib/twurl/cli.rb in twurl-0.9.2 vs lib/twurl/cli.rb in twurl-0.9.3

- old
+ new

@@ -74,10 +74,11 @@ end o.section "Common options:" do trace data + raw_data headers host quiet disable_ssl request_method @@ -234,10 +235,18 @@ options.data[key] = value end end end + def raw_data + on('-r', '--raw-data [data]', 'Sends the specified data as it is in a POST request to the HTTP server.') do |data| + CGI::parse(data).each_pair do |key, value| + options.data[key] = value.first + 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 @@ -294,31 +303,30 @@ def file on('-f', '--file [path_to_file]', 'Specify the path to the file to upload') do |file| if File.file?(file) options.upload['file'] << file - else + else CLI.puts "ERROR: File not found" exit end end end - - def filefield + + def filefield on('-F', '--file-field [field_name]', 'Specify the POST parameter name for the file upload data (default: media)') do |filefield| options.upload['filefield'] = filefield end end - - def base64 + + def base64 on('-b', '--base64', 'Encode the uploaded file as base64 (default: false)') do |base64| options.upload['base64'] = base64 end end end end - class Options < OpenStruct DEFAULT_REQUEST_METHOD = 'get' DEFAULT_HOST = 'api.twitter.com' DEFAULT_PROTOCOL = 'https'