Class: AboutP::Command
- Inherits:
-
Thor
- Object
- Thor
- AboutP::Command
- Defined in:
- lib/about_p/command.rb
Class Method Summary collapse
-
.handle_no_command_error(command, has_namespace = $thor_runner) ⇒ Object
default_command で指定しても「aboutp クエリ」とかで呼び出すと クエリがコマンドだと認識されるので、 handle_no_command_errorをハンドリングする.
Instance Method Summary collapse
Class Method Details
.handle_no_command_error(command, has_namespace = $thor_runner) ⇒ Object
default_command で指定しても「aboutp クエリ」とかで呼び出すと クエリがコマンドだと認識されるので、 handle_no_command_errorをハンドリングする
46 47 48 |
# File 'lib/about_p/command.rb', line 46 def handle_no_command_error(command, has_namespace = $thor_runner) Command.new.search(command) end |
Instance Method Details
#key_config ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/about_p/command.rb', line 22 def key_config key = HighLine.new.ask("Enter API key:") { |q| q.echo = "*" } key = key.to_s Pit.set("about_p", :data => { "api_key" => key }) key end |
#search(query) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/about_p/command.rb', line 9 def search(query) key = api_key || key_config result = API.search(key, query) result.each do |user| extend_size = user.keys.map { |column| column.size }.max user.each do |key, value| puts "#{padding(key, extend_size)}: #{value}" end puts "-"*30 end end |