module Twurl::CLI::AvailableOptions

Public Instance Methods

access_token() click to toggle source
    # File lib/twurl/cli.rb
211 def access_token
212   on('-a', '--access-token [token]', 'Your access token') do |token|
213     options.access_token = token
214   end
215 end
app_only() click to toggle source
    # File lib/twurl/cli.rb
353 def app_only
354   on('--bearer', "Use application-only authentication (Bearer Token)") do |app_only|
355     options.app_only = true
356   end
357 end
base64() click to toggle source
    # File lib/twurl/cli.rb
329 def base64
330   on('-b', '--base64', 'Encode the uploaded file as base64 (default: false)') do |base64|
331     options.upload['base64'] = base64
332   end
333 end
connection_timeout() click to toggle source
    # File lib/twurl/cli.rb
347 def connection_timeout
348   on('--connection-timeout [sec]', Integer, 'Number of seconds to wait for the connection to open (default: 60)') do |connection_timeout|
349     options.connection_timeout = connection_timeout
350   end
351 end
consumer_key() click to toggle source
    # File lib/twurl/cli.rb
199 def consumer_key
200   on('-c', '--consumer-key [key]', "Your consumer key (required)") do |key|
201     options.consumer_key = key ? key : CLI.prompt_for('Consumer key')
202   end
203 end
consumer_secret() click to toggle source
    # File lib/twurl/cli.rb
205 def consumer_secret
206   on('-s', '--consumer-secret [secret]', "Your consumer secret (required)") do |secret|
207     options.consumer_secret = secret ? secret : CLI.prompt_for('Consumer secret')
208   end
209 end
data() click to toggle source
    # File lib/twurl/cli.rb
235 def data
236   on('-d', '--data [data]', 'Sends the specified data in a POST request to the HTTP server.') do |data|
237     if options.args.count { |item| /content-type: (.*)/i.match(item) } > 0
238       options.data[data] = nil
239     else
240       data.split('&').each do |pair|
241         key, value = pair.split('=', 2)
242         options.data[key] = value
243       end
244     end
245   end
246 end
disable_ssl() click to toggle source
    # File lib/twurl/cli.rb
280 def disable_ssl
281   on('-U', '--no-ssl', 'Disable SSL (default: SSL is enabled)') do |use_ssl|
282     options.protocol = 'http'
283   end
284 end
file() click to toggle source
    # File lib/twurl/cli.rb
312 def file
313   on('-f', '--file [path_to_file]', 'Specify the path to the file to upload') do |file|
314     if File.file?(file)
315       options.upload['file'] << file
316     else
317       CLI.puts "ERROR: File not found"
318       exit
319     end
320   end
321 end
filefield() click to toggle source
    # File lib/twurl/cli.rb
323 def filefield
324   on('-F', '--file-field [field_name]', 'Specify the POST parameter name for the file upload data (default: media)') do |filefield|
325     options.upload['filefield'] = filefield
326   end
327 end
headers() click to toggle source
    # File lib/twurl/cli.rb
256 def headers
257   on('-A', '--header [header]', 'Adds the specified header to the request to the HTTP server.') do |header|
258     key, value = header.split(': ')
259     options.headers[key] = value
260   end
261 end
help() click to toggle source
    # File lib/twurl/cli.rb
292 def help
293   on_tail("-h", "--help", "Show this message") do
294     CLI.puts self
295     exit
296   end
297 end
host() click to toggle source
    # File lib/twurl/cli.rb
263 def host
264   on('-H', '--host [host]', 'Specify host to make requests to (default: api.twitter.com)') do |host|
265     if host[PROTOCOL_PATTERN]
266       protocol, protocolless_host = host.split(PROTOCOL_PATTERN, 2)
267       options.host = protocolless_host
268     else
269       options.host = host
270     end
271   end
272 end
json_format() click to toggle source
    # File lib/twurl/cli.rb
335 def json_format
336   on('-j', '--json-pretty', 'Format response body to JSON pretty style') do |json_format|
337     options.json_format = true
338   end
339 end
options() click to toggle source
    # File lib/twurl/cli.rb
181 def options
182   Twurl.options
183 end
proxy() click to toggle source
    # File lib/twurl/cli.rb
306 def proxy
307   on('-P', '--proxy [proxy]', 'Specify HTTP proxy to forward requests to (default: No proxy)') do |proxy|
308     options.proxy = proxy
309   end
310 end
quiet() click to toggle source
    # File lib/twurl/cli.rb
274 def quiet
275   on('-q', '--quiet', 'Suppress all output (default: output is printed to STDOUT)') do |quiet|
276     options.output = StringIO.new
277   end
278 end
raw_data() click to toggle source
    # File lib/twurl/cli.rb
248 def raw_data
249   on('-r', '--raw-data [data]', 'Sends the specified data as it is in a POST request to the HTTP server.') do |data|
250     CGI::parse(data).each_pair do |key, value|
251       options.data[key] = value.first
252     end
253   end
254 end
request_method() click to toggle source
    # File lib/twurl/cli.rb
286 def request_method
287   on('-X', '--request-method [method]', 'Request method (default: GET)') do |request_method|
288     options.request_method = request_method.downcase
289   end
290 end
section(heading, &block) click to toggle source
    # File lib/twurl/cli.rb
185 def section(heading, &block)
186   separator ""
187   separator heading
188 
189   instance_eval(&block)
190 end
timeout() click to toggle source
    # File lib/twurl/cli.rb
341 def timeout
342   on('--timeout [sec]', Integer, 'Number of seconds to wait for the request to be read (default: 60)') do |timeout|
343     options.timeout = timeout
344   end
345 end
token_secret() click to toggle source
    # File lib/twurl/cli.rb
217 def token_secret
218   on('-S', '--token-secret [secret]', "Your token secret") do |secret|
219     options.token_secret = secret
220   end
221 end
trace() click to toggle source
    # File lib/twurl/cli.rb
229 def trace
230   on('-t', '--[no-]trace', 'Trace request/response traffic (default: --no-trace)') do |trace|
231     options.trace = trace
232   end
233 end
tutorial() click to toggle source
    # File lib/twurl/cli.rb
192 def tutorial
193   on('-T', '--tutorial', "Narrative overview of how to get started using Twurl") do
194     CLI.puts IO.read(README)
195     exit
196   end
197 end
username() click to toggle source
    # File lib/twurl/cli.rb
223 def username
224   on('-u', '--username [username]', 'Username of account to authorize (required)') do |username|
225     options.username = username
226   end
227 end
version() click to toggle source
    # File lib/twurl/cli.rb
299 def version
300   on_tail("-v", "--version", "Show version") do
301     CLI.puts Version
302     exit
303   end
304 end