Module: Twurl::CLI::AvailableOptions

Defined in:
lib/twurl/cli.rb

Instance Method Summary collapse

Instance Method Details

#access_tokenObject



195
196
197
198
199
# File 'lib/twurl/cli.rb', line 195

def access_token
  on('-a', '--access-token [token]', 'Your access token') do |token|
    options.access_token = token
  end
end

#consumer_keyObject



183
184
185
186
187
# File 'lib/twurl/cli.rb', line 183

def consumer_key
  on('-c', '--consumer-key [key]', "Your consumer key (required)") do |key|
    options.consumer_key = key ? key : CLI.prompt_for('Consumer key')
  end
end

#consumer_secretObject



189
190
191
192
193
# File 'lib/twurl/cli.rb', line 189

def consumer_secret
  on('-s', '--consumer-secret [secret]', "Your consumer secret (required)") do |secret|
    options.consumer_secret = secret ? secret : CLI.prompt_for('Consumer secret')
  end
end

#dataObject



225
226
227
228
229
230
231
232
# File 'lib/twurl/cli.rb', line 225

def data
  on('-d', '--data [data]', 'Sends the specified data in a POST request to the HTTP server.') do |data|
    data.split('&').each do |pair|
      key, value = pair.split('=', 2)
      options.data[key] = value
    end
  end
end

#disable_sslObject



258
259
260
261
262
# File 'lib/twurl/cli.rb', line 258

def disable_ssl
  on('-U', '--no-ssl', 'Disable SSL (default: SSL is enabled)') do |use_ssl|
    options.protocol = 'http'
  end
end

#headersObject



234
235
236
237
238
239
# File 'lib/twurl/cli.rb', line 234

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

#helpObject



270
271
272
273
274
275
# File 'lib/twurl/cli.rb', line 270

def help
  on_tail("-h", "--help", "Show this message") do
    CLI.puts self
    exit
  end
end

#hostObject



241
242
243
244
245
246
247
248
249
250
# File 'lib/twurl/cli.rb', line 241

def host
  on('-H', '--host [host]', 'Specify host to make requests to (default: api.twitter.com)') do |host|
    if host[PROTOCOL_PATTERN]
      protocol, protocolless_host = host.split(PROTOCOL_PATTERN, 2)
      options.host = protocolless_host
    else
      options.host = host
    end
  end
end

#optionsObject



165
166
167
# File 'lib/twurl/cli.rb', line 165

def options
  Twurl.options
end

#passwordObject



213
214
215
216
217
# File 'lib/twurl/cli.rb', line 213

def password
  on('-p', '--password [password]', 'Password of account to authorize (required)') do |password|
    options.password = password ? password : CLI.prompt_for('Password')
  end
end

#proxyObject



284
285
286
287
288
# File 'lib/twurl/cli.rb', line 284

def proxy
  on('-P', '--proxy [proxy]', 'Specify HTTP proxy to forward requests to (default: No proxy)') do |proxy|
    options.proxy = proxy
  end
end

#quietObject



252
253
254
255
256
# File 'lib/twurl/cli.rb', line 252

def quiet
  on('-q', '--quiet', 'Suppress all output (default: output is printed to STDOUT)') do |quiet|
    options.output = StringIO.new
  end
end

#request_methodObject



264
265
266
267
268
# File 'lib/twurl/cli.rb', line 264

def request_method
  on('-X', '--request-method [method]', 'Request method (default: GET)') do |request_method|
    options.request_method = request_method.downcase
  end
end

#section(heading, &block) ⇒ Object



169
170
171
172
173
174
# File 'lib/twurl/cli.rb', line 169

def section(heading, &block)
  separator ""
  separator heading

  instance_eval(&block)
end

#token_secretObject



201
202
203
204
205
# File 'lib/twurl/cli.rb', line 201

def token_secret
  on('-S', '--token-secret', "Your token secret") do |secret|
    options.token_secret = secret
  end
end

#traceObject



219
220
221
222
223
# File 'lib/twurl/cli.rb', line 219

def trace
  on('-t', '--[no-]trace', 'Trace request/response traffic (default: --no-trace)') do |trace|
    options.trace = trace
  end
end

#tutorialObject



176
177
178
179
180
181
# File 'lib/twurl/cli.rb', line 176

def tutorial
  on('-T', '--tutorial', "Narrative overview of how to get started using Twurl") do
    CLI.puts IO.read(README)
    exit
  end
end

#usernameObject



207
208
209
210
211
# File 'lib/twurl/cli.rb', line 207

def username
  on('-u', '--username [username]', 'Username of account to authorize (required)') do |username|
    options.username = username
  end
end

#versionObject



277
278
279
280
281
282
# File 'lib/twurl/cli.rb', line 277

def version
  on_tail("-v", "--version", "Show version") do
    CLI.puts Version
    exit
  end
end