Module: Twurl::CLI::AvailableOptions

Defined in:
lib/twurl/cli.rb

Instance Method Summary collapse

Instance Method Details

#access_tokenObject



150
151
152
153
154
# File 'lib/twurl/cli.rb', line 150

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

#consumer_keyObject



138
139
140
141
142
# File 'lib/twurl/cli.rb', line 138

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



144
145
146
147
148
# File 'lib/twurl/cli.rb', line 144

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



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

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('=')
      options.data[key] = value
    end
  end
end

#disable_sslObject



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

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

#helpObject



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

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

#hostObject



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

def host
  on('-H', '--host [host]', 'Specify host to make requests to (default: api.twitter.com)') do |host|
    options.host = host
  end
end

#optionsObject



120
121
122
# File 'lib/twurl/cli.rb', line 120

def options
  Twurl.options
end

#passwordObject



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

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

#quietObject



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

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

#request_methodObject



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

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



124
125
126
127
128
129
# File 'lib/twurl/cli.rb', line 124

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

  instance_eval(&block)
end

#token_secretObject



156
157
158
159
160
# File 'lib/twurl/cli.rb', line 156

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

#traceObject



174
175
176
177
178
# File 'lib/twurl/cli.rb', line 174

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

#tutorialObject



131
132
133
134
135
136
# File 'lib/twurl/cli.rb', line 131

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

#usernameObject



162
163
164
165
166
# File 'lib/twurl/cli.rb', line 162

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