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
- #help ⇒ Object
- #host ⇒ Object
- #options ⇒ Object
- #password ⇒ Object
- #quiet ⇒ Object
- #request_method ⇒ Object
- #section(heading, &block) ⇒ Object
- #token_secret ⇒ Object
- #trace ⇒ Object
- #tutorial ⇒ Object
- #username ⇒ Object
Instance Method Details
#access_token ⇒ Object
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| .access_token = token end end |
#consumer_key ⇒ Object
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| .consumer_key = key ? key : CLI.prompt_for('Consumer key') end end |
#consumer_secret ⇒ Object
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| .consumer_secret = secret ? secret : CLI.prompt_for('Consumer secret') end end |
#data ⇒ Object
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('=') .data[key] = value end end end |
#disable_ssl ⇒ Object
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| .protocol = 'http' end end |
#help ⇒ Object
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 |
#host ⇒ Object
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| .host = host end end |
#options ⇒ Object
120 121 122 |
# File 'lib/twurl/cli.rb', line 120 def Twurl. end |
#password ⇒ Object
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| .password = password ? password : CLI.prompt_for('Password') end end |
#quiet ⇒ Object
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| .output = StringIO.new end end |
#request_method ⇒ Object
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| .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_secret ⇒ Object
156 157 158 159 160 |
# File 'lib/twurl/cli.rb', line 156 def token_secret on('-S', '--token-secret', "Your token secret") do |secret| .token_secret = secret end end |
#trace ⇒ Object
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| .trace = trace end end |
#tutorial ⇒ Object
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 |
#username ⇒ Object
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| .username = username end end |