Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions Library/Homebrew/cmd/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ def search_args
If no <text> is provided, list all locally available formulae (including tapped ones).
No online search is performed.
EOS
switch "--formulae",
description: "Without <text>, list all locally available formulae (no online search is performed). " \
"With <text>, search online and locally for formulae."
switch "--casks",
description: "List all locally available casks (including tapped ones). "\
"No online search is performed."
description: "Without <text>, list all locally available casks (including tapped ones, no online " \
"search is performed). With <text>, search online and locally for casks."
switch "--desc",
description: "Search for formulae with a description matching <text> and casks with "\
"a name matching <text>."
Expand All @@ -65,6 +68,8 @@ def search

if args.remaining.empty?
if args.casks?
raise UsageError, "specifying both --formulae and --casks requires an argument!" if args.formulae?

puts Formatter.columns(Cask::Cask.to_a.map(&:full_name).sort)
else
puts Formatter.columns(Formula.full_names.sort)
Expand All @@ -88,14 +93,17 @@ def search
local_casks = search_casks(string_or_regex)
remote_casks = remote_results[:casks]
all_casks = local_casks + remote_casks
print_formulae = args.formulae?
print_casks = args.casks?
print_formulae = print_casks = true if !print_formulae && !print_casks

Comment thread
vidusheeamoli marked this conversation as resolved.
Outdated
if all_formulae.any?
if print_formulae && all_formulae.any?
ohai "Formulae"
puts Formatter.columns(all_formulae)
end

if all_casks.any?
puts if all_formulae.any?
if print_casks && all_casks.any?
puts if args.formulae? && all_formulae.any?
ohai "Casks"
puts Formatter.columns(all_casks)
end
Expand Down
4 changes: 3 additions & 1 deletion docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,10 @@ search for *`text`* is extended online to `homebrew/core` and `homebrew/cask`.
If no *`text`* is provided, list all locally available formulae (including tapped
ones). No online search is performed.

* `--formulae`:
Without *`text`*, list all locally available formulae (no online search is performed). With *`text`*, search online and locally for formulae.
* `--casks`:
List all locally available casks (including tapped ones). No online search is performed.
Without *`text`*, list all locally available casks (including tapped ones, no online search is performed). With *`text`*, search online and locally for casks.
* `--desc`:
Search for formulae with a description matching *`text`* and casks with a name matching *`text`*.
* `--macports`:
Expand Down
2 changes: 1 addition & 1 deletion manpages/brew-cask.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BREW\-CASK" "1" "February 2020" "Homebrew" "brew-cask"
.TH "BREW\-CASK" "1" "March 2020" "Homebrew" "brew-cask"
.
.SH "NAME"
\fBbrew\-cask\fR \- a friendly binary installer for macOS
Expand Down
8 changes: 6 additions & 2 deletions manpages/brew.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BREW" "1" "February 2020" "Homebrew" "brew"
.TH "BREW" "1" "March 2020" "Homebrew" "brew"
.
.SH "NAME"
\fBbrew\fR \- The Missing Package Manager for macOS
Expand Down Expand Up @@ -548,8 +548,12 @@ Perform a substring search of cask tokens and formula names for \fItext\fR\. If
If no \fItext\fR is provided, list all locally available formulae (including tapped ones)\. No online search is performed\.
.
.TP
\fB\-\-formulae\fR
Without \fItext\fR, list all locally available formulae (no online search is performed)\. With \fItext\fR, search online and locally for formulae\.
.
.TP
\fB\-\-casks\fR
List all locally available casks (including tapped ones)\. No online search is performed\.
Without \fItext\fR, list all locally available casks (including tapped ones, no online search is performed)\. With \fItext\fR, search online and locally for casks\.
.
.TP
\fB\-\-desc\fR
Expand Down