There are a number of websites that allow you to search for Homebrew packages, such as Braumeister. With Homebrew itself, this is done with
- lists all locally available formula files (i.e., the ones that live in the Taps you’ve installed on your system).
brew search <text>
brew search /text/
- returns a list of formula names that match the regular expression.
brew search /.+audio.+/yields only switchaudio-osx.
brew search --desc (<text>|/text/)
- returns a list of formulae with descriptions matching the search term.
- For example,
brew search --desc musiccurrently returns 27 formulae and their descriptions:
brew search (
- performs a search for the search term on the given package manager’s website.
- For example,
brew search --ubuntu abcnavigates your web browser to this page.
brew search didn’t have an integration test when I found it. My new test boosted its coverage from 16% to 71% (yay), though a big chunk of its behavior still remains untested (boo). Oh well. In the new test, a formula file is written to the
Homebrew/homebrew-core tap (in the exact same way that it’s done in several other integration tests, e.g., for
brew home and
brew log). As is done in the test for
brew desc, it makes the same assertions that the
desc_cache.json file is created during the course of the test (this time, when the
--desc flag is passed to
brew search). It also asserts that
testball (the test formula file) is a search result for these four calls to
brew search brew search testball brew search homebrew/homebrew-core/testball brew search --desc Some test
It then proceeds to test these lines in
brew search employs Homebrew’s
exec_browser utility method to navigate your web browser to the desired path. An efficient, DRY way to test the six different flags is to create a single hash and then iterate over the hash to make the relevant assertions:
- the hash associates each flag with its URL.
- inside the
each...doblock, each call to the
cmdhelper method sets the
HOMEBREW_BROWSERenvironment variable equal to
echo(just like in the test for
- an assertion is made for each flag.
brew search --debian testballshould spit out the string for this webpage.
- at the end of test, as usual, the newly created files are removed from existence.