From 67d012afccc1bb19b91e29bbd99b699579d6d0b3 Mon Sep 17 00:00:00 2001 From: vidusheeamoli Date: Wed, 4 Mar 2020 17:56:29 +0530 Subject: [PATCH 1/2] search: add separate flag for formulae --- Library/Homebrew/cmd/search.rb | 14 +++++++++++--- docs/Manpage.md | 2 ++ manpages/brew-cask.1 | 2 +- manpages/brew.1 | 6 +++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index fee4468a2d9d7..f40a976e48210 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -36,6 +36,9 @@ def search_args If no is provided, list all locally available formulae (including tapped ones). No online search is performed. EOS + switch "--formulae", + description: "List all locally available formulae. "\ + "No online search is performed." switch "--casks", description: "List all locally available casks (including tapped ones). "\ "No online search is performed." @@ -65,6 +68,8 @@ def search if args.remaining.empty? if args.casks? + raise UsageError, "Cannot specify --formulae and --casks without an argument!" if args.formulae? + puts Formatter.columns(Cask::Cask.to_a.map(&:full_name).sort) else puts Formatter.columns(Formula.full_names.sort) @@ -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 - 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 diff --git a/docs/Manpage.md b/docs/Manpage.md index 0560e0bea5b1c..abfbaf73f248c 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -425,6 +425,8 @@ 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`: + List all locally available formulae. No online search is performed. * `--casks`: List all locally available casks (including tapped ones). No online search is performed. * `--desc`: diff --git a/manpages/brew-cask.1 b/manpages/brew-cask.1 index bf6bf49f9ad93..7378de58126fb 100644 --- a/manpages/brew-cask.1 +++ b/manpages/brew-cask.1 @@ -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 diff --git a/manpages/brew.1 b/manpages/brew.1 index bb74d1aaf23fa..66c217dfc40cc 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -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 @@ -548,6 +548,10 @@ 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 +List all locally available formulae\. No online search is performed\. +. +.TP \fB\-\-casks\fR List all locally available casks (including tapped ones)\. No online search is performed\. . From 6ead927500f8122bd3968a0c639e44732dd4d2af Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 4 Mar 2020 13:14:39 +0000 Subject: [PATCH 2/2] cmd/search: tweak documentation text. --- Library/Homebrew/cmd/search.rb | 10 +++++----- docs/Manpage.md | 4 ++-- manpages/brew.1 | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index f40a976e48210..61833ca7656a9 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -37,11 +37,11 @@ def search_args No online search is performed. EOS switch "--formulae", - description: "List all locally available formulae. "\ - "No online search is performed." + description: "Without , list all locally available formulae (no online search is performed). " \ + "With , search online and locally for formulae." switch "--casks", - description: "List all locally available casks (including tapped ones). "\ - "No online search is performed." + description: "Without , list all locally available casks (including tapped ones, no online " \ + "search is performed). With , search online and locally for casks." switch "--desc", description: "Search for formulae with a description matching and casks with "\ "a name matching ." @@ -68,7 +68,7 @@ def search if args.remaining.empty? if args.casks? - raise UsageError, "Cannot specify --formulae and --casks without an argument!" if args.formulae? + 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 diff --git a/docs/Manpage.md b/docs/Manpage.md index abfbaf73f248c..6553ccf42c7e8 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -426,9 +426,9 @@ If no *`text`* is provided, list all locally available formulae (including tappe ones). No online search is performed. * `--formulae`: - List all locally available formulae. No online search is performed. + 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`: diff --git a/manpages/brew.1 b/manpages/brew.1 index 66c217dfc40cc..e3d8cbf9b8c8f 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -549,11 +549,11 @@ If no \fItext\fR is provided, list all locally available formulae (including tap . .TP \fB\-\-formulae\fR -List all locally available formulae\. No online search is performed\. +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