Class: Bcli::Commands::Bookmarks::Search

Inherits:
Bcli::Command show all
Defined in:
lib/bcli/commands/bookmarks/search.rb

Instance Method Summary collapse

Methods inherited from Bcli::Command

#ask, #client, #config, #credentials, #download, #link_to, #logger, #open_in_browser, #parse_json, #pastel, #prompt

Constructor Details

#initialize(options) ⇒ Search

Returns a new instance of Search.



9
10
11
# File 'lib/bcli/commands/bookmarks/search.rb', line 9

def initialize(options)
  @options = options
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/bcli/commands/bookmarks/search.rb', line 13

def execute(input: $stdin, output: $stdout)
  res = client.get("/bookmarks?q[title_or_url_cont]=#{query}")
  if res.success?
    output.puts handle_search_response(parse_json(res))
  else
    output.puts pastel.red res.inspect
  end
end