Class: Homebrew::Cmd::SearchCmd

Inherits:
AbstractCommand show all
Defined in:
cmd/search.rb

Constant Summary collapse

PACKAGE_MANAGERS =
{
  repology:  ->(query) { "https://repology.org/projects/?search=#{query}" },
  macports:  ->(query) { "https://ports.macports.org/search/?q=#{query}" },
  fink:      ->(query) { "https://pdb.finkproject.org/pdb/browse.php?summary=#{query}" },
  opensuse:  ->(query) { "https://software.opensuse.org/search?q=#{query}" },
  fedora:    ->(query) { "https://packages.fedoraproject.org/search?query=#{query}" },
  archlinux: ->(query) { "https://archlinux.org/packages/?q=#{query}" },
  debian:    lambda { |query|
    "https://packages.debian.org/search?keywords=#{query}&searchon=names&suite=all&section=all"
  },
  ubuntu:    lambda { |query|
    "https://packages.ubuntu.com/search?keywords=#{query}&searchon=names&suite=all&section=all"
  },
}.freeze

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#runvoid

This method returns an undefined value.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'cmd/search.rb', line 66

def run
  return if search_package_manager

  query = args.named.join(" ")
  string_or_regex = Search.query_regexp(query)

  if args.desc?
    if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
      raise UsageError, "`brew search --desc` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!"
    end

    Search.search_descriptions(string_or_regex, args)
  elsif args.pull_request?
    search_pull_requests(query)
  else
    formulae, casks = Search.search_names(string_or_regex, args)
    print_results(formulae, casks, query)
  end

  puts "Use `brew desc` to list packages with a short description." if args.verbose?

  print_regex_help
end