Merge pull request #5590 from GauthamGoli/search-args-docs

search: Add descriptions to option declarations
This commit is contained in:
Mike McQuaid 2019-01-24 12:44:37 +00:00 committed by GitHub
commit 2dce15e9e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,20 +41,38 @@ module Homebrew
}, },
}.freeze }.freeze
def search(argv = ARGV) def search_args
CLI::Parser.parse(argv) do Homebrew::CLI::Parser.new do
switch "--desc" usage_banner <<~EOS
`search`, `-S` [<options>] (<text>|`/`<text>`/`)
Perform a substring search of cask tokens and formula names for <text>. If <text>
is surrounded with slashes, then it is interpreted as a regular expression.
The search for <text> is extended online to `homebrew/core` and `homebrew/cask`.
If no <text> is passed, display all locally available formulae (including tapped ones).
No online search is performed.
EOS
switch "--casks",
description: "Display all locally available casks (including tapped ones). "\
"No online search is performed."
switch "--desc",
description: "search formulae with a description matching <text> and casks with "\
"a name matching <text>."
package_manager_switches = PACKAGE_MANAGERS.keys.map { |name| "--#{name}" } package_manager_switches = PACKAGE_MANAGERS.keys.map { |name| "--#{name}" }
package_manager_switches.each do |s| package_manager_switches.each do |s|
switch s switch s,
description: "Search for <text> in the given package manager's list."
end end
switch :verbose
switch "--casks" switch :debug
conflicts(*package_manager_switches) conflicts(*package_manager_switches)
end end
end
def search
search_args.parse
if package_manager = PACKAGE_MANAGERS.find { |name,| args[:"#{name}?"] } if package_manager = PACKAGE_MANAGERS.find { |name,| args[:"#{name}?"] }
_, url = package_manager _, url = package_manager