search: Add descriptions to option declarations

This commit is contained in:
Gautham Goli 2019-01-23 10:14:31 +05:30
parent 70c5b6f804
commit e2e4f93f06
No known key found for this signature in database
GPG Key ID: 6A9ABBC284468364

View File

@ -41,20 +41,38 @@ module Homebrew
},
}.freeze
def search(argv = ARGV)
CLI::Parser.parse(argv) do
switch "--desc"
def search_args
Homebrew::CLI::Parser.new do
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.each do |s|
switch s
switch s,
description: "Search for <text> in the given package manager's list."
end
switch "--casks"
switch :verbose
switch :debug
conflicts(*package_manager_switches)
end
end
def search
search_args.parse
if package_manager = PACKAGE_MANAGERS.find { |name,| args[:"#{name}?"] }
_, url = package_manager