Module: Twurl::CLI::AvailableOptions
- Defined in:
- lib/twurl/cli.rb
Instance Method Summary collapse
- #access_token ⇒ Object
- #consumer_key ⇒ Object
- #consumer_secret ⇒ Object
- #data ⇒ Object
- #disable_ssl ⇒ Object
- #headers ⇒ Object
- #help ⇒ Object
- #host ⇒ Object
- #options ⇒ Object
- #password ⇒ Object
- #proxy ⇒ Object
- #quiet ⇒ Object
- #request_method ⇒ Object
- #section(heading, &block) ⇒ Object
- #token_secret ⇒ Object
- #trace ⇒ Object
- #tutorial ⇒ Object
- #username ⇒ Object
- #version ⇒ Object
Instance Method Details
#access_token ⇒ Object
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| .access_token = token end end |
#consumer_key ⇒ Object
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| .consumer_key = key ? key : CLI.prompt_for('Consumer key') end end |
#consumer_secret ⇒ Object
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| .consumer_secret = secret ? secret : CLI.prompt_for('Consumer secret') end end |
#data ⇒ Object
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) .data[key] = value end end end |
#disable_ssl ⇒ Object
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| .protocol = 'http' end end |
#headers ⇒ Object
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(': ') .headers[key] = value end end |
#help ⇒ Object
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 |
#host ⇒ Object
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) .host = protocolless_host else .host = host end end end |
#options ⇒ Object
165 166 167 |
# File 'lib/twurl/cli.rb', line 165 def Twurl. end |
#password ⇒ Object
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| .password = password ? password : CLI.prompt_for('Password') end end |
#proxy ⇒ Object
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| .proxy = proxy end end |
#quiet ⇒ Object
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| .output = StringIO.new end end |
#request_method ⇒ Object
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| .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_secret ⇒ Object
201 202 203 204 205 |
# File 'lib/twurl/cli.rb', line 201 def token_secret on('-S', '--token-secret', "Your token secret") do |secret| .token_secret = secret end end |
#trace ⇒ Object
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| .trace = trace end end |
#tutorial ⇒ Object
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 |
#username ⇒ Object
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| .username = username end end |