Class: Homebrew::Cmd::SearchCmd Private

Inherits:
AbstractCommand show all
Defined in:
cmd/search.rb,
sorbet/rbi/dsl/homebrew/cmd/search_cmd.rbi

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Defined Under Namespace

Classes: Args

Constant Summary collapse

PACKAGE_MANAGERS =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

T.let(package_managers.freeze, T::Hash[Symbol, T.proc.params(query: String).returns(String)])

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_incompatible, #pretty_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#args ⇒ Homebrew::Cmd::SearchCmd::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



10
# File 'sorbet/rbi/dsl/homebrew/cmd/search_cmd.rbi', line 10

def args; end

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:

  • query (String)
  • found_matches (Boolean)


118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'cmd/search.rb', line 118

def print_missing_formula_help(query, found_matches)
  return unless $stdout.tty?
  return if query.match?(Search::QUERY_REGEX)

  reason = MissingFormula.reason(query, silent: true)
  return if reason.nil?

  if found_matches
    puts
    puts "If you meant #{query.inspect} specifically:"
  end
  puts reason
end

#run ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'cmd/search.rb', line 71

def run
  return if search_package_manager!

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

  if args.desc?
    Search.search_descriptions(string_or_regex, args, show_missing: true)
  elsif args.pull_request?
    only = if args.open? && !args.closed?
      "open"
    elsif args.closed? && !args.open?
      "closed"
    end

    GitHub.print_pull_requests_matching(query, only)
  else
    formulae, casks = Search.search_names(string_or_regex, args)
    count = formulae.size + casks.size

    if formulae.any?
      if $stdout.tty? && !args.quiet?
        ohai "Formulae", Formatter.columns(formulae)
      else
        puts formulae
      end
    end
    puts if formulae.any? && casks.any?
    if casks.any?
      if $stdout.tty? && !args.quiet?
        ohai "Casks", Formatter.columns(casks)
      else
        puts casks
      end
    end

    print_missing_formula_help(query, count.positive?) if casks.exclude?(query)

    odie "No formulae or casks found for #{query.inspect}." if count.zero?
  end

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

  print_regex_help
end