Class: Bcli::Commands::Snippets::Search

Inherits:
Bcli::Command show all
Defined in:
lib/bcli/commands/snippets/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/snippets/search.rb', line 9

def initialize(options)
  @options = options
end

Instance Method Details

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



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

def execute(input: $stdin, output: $stdout, page: 1)
  res = client.get("/snippets?q[name_or_code_cont]=#{query}&page=#{page}")

  if res.success?
    output.puts handle_search_response(res)
  else
    output.puts pastel.red res.inspect
  end
end