lib/twurl/cli.rb in twurl-0.9.4 vs lib/twurl/cli.rb in twurl-0.9.5

- old
+ new

@@ -1,8 +1,8 @@ module Twurl class CLI - SUPPORTED_COMMANDS = %w(authorize accounts alias set) + SUPPORTED_COMMANDS = %w(authorize accounts bearer_tokens alias set) DEFAULT_COMMAND = 'request' PATH_PATTERN = /^\/\w+/ PROTOCOL_PATTERN = /^\w+:\/\// README = File.dirname(__FILE__) + '/../../README.md' @output ||= STDOUT @@ -26,10 +26,12 @@ controller = case options.command when 'authorize' AuthorizationController when 'accounts' AccountInformationController + when 'bearer_tokens' + AppOnlyTokenInformationController when 'alias' AliasesController when 'set' ConfigurationController when 'request' @@ -85,12 +87,14 @@ version proxy file filefield base64 + json_format timeout connection_timeout + app_only end end arguments = option_parser.parse!(args) Twurl.options.command = extract_command!(arguments) @@ -325,18 +329,30 @@ on('-b', '--base64', 'Encode the uploaded file as base64 (default: false)') do |base64| options.upload['base64'] = base64 end end + def json_format + on('-j', '--json-pretty', 'Format response body to JSON pretty style') do |json_format| + options.json_format = true + end + end + def timeout on('--timeout [sec]', Integer, 'Number of seconds to wait for the request to be read (default: 60)') do |timeout| options.timeout = timeout end end def connection_timeout on('--connection-timeout [sec]', Integer, 'Number of seconds to wait for the connection to open (default: 60)') do |connection_timeout| options.connection_timeout = connection_timeout + end + end + + def app_only + on('--bearer', "Use application-only authentication (Bearer Token)") do |app_only| + options.app_only = true end end end end