Class: Bicho::CLI::Commands::Search
- Inherits:
-
Bicho::CLI::Command
- Object
- Bicho::CLI::Command
- Bicho::CLI::Commands::Search
- Defined in:
- lib/bicho/cli/commands/search.rb
Overview
Command to search for bugs.
Instance Attribute Summary
Attributes inherited from Bicho::CLI::Command
Instance Method Summary collapse
Methods inherited from Bicho::CLI::Command
#initialize, opt, options, #parse_options, #parser
Methods included from Logging
Constructor Details
This class inherits a constructor from Bicho::CLI::Command
Instance Method Details
#do(global_opts, opts, _args) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/bicho/cli/commands/search.rb', line 45 def do(global_opts, opts, _args) server = ::Bicho::Client.new(global_opts[:bugzilla]) Bicho.client = server # for most parameter we accept arrays, and also multi mode # this means parameters come in arrays of arrays query = ::Bicho::Query.new opts.each do |n, v| # skip any option that is not part of SEARCH_FIELDS next unless Bicho::SEARCH_FIELDS.map { |x| x[0] }.include?(n) next if v.nil? || v.flatten.empty? v.flatten.each do |single_val| query.send(n.to_sym, single_val) end end case opts[:format] when 'prometheus' STDOUT.puts Bicho::Export.to_prometheus_push_gateway(query) else server.search_bugs(query).each do |bug| t.say("#{t.color(bug.id.to_s, :headline)} #{bug.summary}") end end 0 end |