Class: Rst::CLI
- Inherits:
-
Object
- Object
- Rst::CLI
- Defined in:
- lib/rst/cli.rb
Instance Method Summary collapse
-
#initialize(client) ⇒ CLI
constructor
A new instance of CLI.
- #run(options, args = []) ⇒ Object
- #user(params = {}, args = []) ⇒ Object
- #users_search(params = {}, args = []) ⇒ Object
- #world(params = {}, args = []) ⇒ Object
Constructor Details
#initialize(client) ⇒ CLI
Returns a new instance of CLI.
3 4 5 |
# File 'lib/rst/cli.rb', line 3 def initialize(client) @client = client end |
Instance Method Details
#run(options, args = []) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rst/cli.rb', line 7 def run(, args = []) command = args[0] rest_of_args = args[1, args.length] results = send(command.gsub(/-/, "_"), , rest_of_args) puts results.join("\n\n") rescue Exception => e puts "ERROR: #{e.}" if [:debug] puts e.backtrace.join("\n") else puts "Run with --trace for the full backtrace." end exit 1 end |
#user(params = {}, args = []) ⇒ Object
30 31 32 33 34 |
# File 'lib/rst/cli.rb', line 30 def user(params = {}, args = []) username = args[0] raise "Username is required." unless username statuses(:messages_user, params.merge(:username => username)) end |
#users_search(params = {}, args = []) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rst/cli.rb', line 36 def users_search(params = {}, args = []) search_pattern = args[0] raise "Username search pattern is required." unless search_pattern users = @client.users_search(:pattern => search_pattern) if users.empty? ["No users that match."] else users.map{|u| Rst::UserPresenter.new(u) } end end |
#world(params = {}, args = []) ⇒ Object
26 27 28 |
# File 'lib/rst/cli.rb', line 26 def world(params = {}, args = []) statuses(:messages_all, params) end |