diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 5f51d1c758..aff503cb2d 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -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` [] (|`/``/`) + + Perform a substring search of cask tokens and formula names for . If + is surrounded with slashes, then it is interpreted as a regular expression. + The search for is extended online to `homebrew/core` and `homebrew/cask`. + + If no 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 and casks with "\ + "a name matching ." package_manager_switches = PACKAGE_MANAGERS.keys.map { |name| "--#{name}" } - package_manager_switches.each do |s| - switch s + switch s, + description: "Search for 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