Originated as part of the discussion in https://github.com/Homebrew/brew/issues/6950.
Having flags that mimic subcommands is a poor interface鈥攖hey have low discoverability and are confusing. The one command that does it is brew search, and my argument is users would be better served by reinstating brew cask search.
Let鈥檚 look at the current search situation:
brew search # lists all formulae
brew search <argument> # search for <argument> in formulae and casks
brew search --casks # lists all casks
brew search --casks <argument> # searches for <argument> in formulae and casks
So without the --casks flag, half the time you only get formulae, the other half you get formulae and casks; if you give the --casks flag, half the time you only get casks, the other half you get formulae and casks. That鈥檚 wholly unintuitive. One of the commands is useless (brew search --casks <argument>) but you wouldn鈥檛 know without trying and could be forgiven for thinking it only showed casks.
Compare that to reinstating brew cask search:
brew search # lists all formulae
brew search <argument> # searches for <argument> in formulae
brew cask search # lists all casks
brew cask search <argument> # searches for <argument> in casks
All commands do what they say all the time. We lose the ability to show both casks and formulae at once but gain clarity, which is more important. We already require two commands for every other task鈥攍ike upgrade, which I鈥檇 wager is called way more often (do we have data on that?).
If having a single command to search both formulae and casks is a must, I鈥檇 recommend an --all, or --both, or --fac (formulae and casks) flag.
In essence, every command that needs the option to run on just formulae or just casks should be under their respective subcommand. update works as standalone because it deals with taps, not formulae and casks. One could also make a case for the consolidation of info (if there鈥檚 a formulae and a cask share a name, it doesn鈥檛 seem problematic that info would show both).
Make Homebrew鈥檚 interface more consistent, thus clearer.
Following the principle of least astonishment is a benefit to every user.
Get rid of the --casks flag and make brew search always show both:
brew search # lists all formulae and casks
brew search <argument> # search for <argument> in formulae and casks
Make brew search always show both; make --casks always search only for casks; add a --formulae flag to search only for formulae. I don鈥檛 think this is a good idea, but it鈥檚 still better than the current situation:
brew search # lists all formulae and casks
brew search <argument> # search for <argument> in formulae and casks
brew search --formulae # lists all formulae
brew search --formulae <argument> # search for <argument> in formulae
brew search --casks # lists all casks
brew search --casks <argument>. # search for <argument> in casks
Make
brew searchalways show both; make--casksalways search _only_ for casks; add a--formulaeflag to search _only_ for formulae. I don鈥檛 think this is a good idea, but it鈥檚 still better than the current situation:
馃憤 this sounds good to me.
Always showing both improves the discoverability of cask formulae themselves.
Always showing both improves the discoverability of cask formulae themselves.
Just so we don鈥檛 get confused: there鈥檙e casks and there鈥檙e formulae, we consider them different things.
But to your point, I don鈥檛 think lack of discoverability in casks is a thing. In fact, many people straight up prefer casks, or just use casks, or just submit casks because they find them easier to build. I regularly have to send people to non-Cask Homebrew for submissions because they鈥檝e made a cask for an open-source CLI-only tool, which should default to Homebrew. Going by number of stars alone, homebrew-cask has over twice as many stars as homebrew-core.
@vitorgalvao Well, without denying that your information is quite surprising, I have to agree - keys as logic switches never seemed to be a good solution. I can't remember for how many occasions my fingers have typed brew cask search without any doubt in their confidence.
Let me suggest my option:
brew search <formulae> # search for formul忙s
brew cask search <cask> # search for casks
brew search --desc text|regexp # cross-referencing search
Why so? Well, my point is that cross-search is mainly used to search tools by description, i.e. to find a suitable utility with certain functionality, and it is most likely that the user will not care whether it is a formula, or cask.
Hello, I would like to work on this. Would appreciate pointers to get started.
Make brew search always show both; make --casks always search only for casks; add a
--formulae flag to search only for formulae.
This looks like a good solution to me. What do you think @MikeMcQuaid @vitorgalvao ? :)
Having casks behave as a completely separate part of homebrew always seemed weird to me so I'm in favor of anything that removes the need to specify that you're operating on casks (while keeping the option).
@vidusheeamoli Sounds like a good solution to me! If you have more specific questions we can provide pointers.
Hello! After exploring the codebase for a few days now, things make a lot more sense to me and I am focusing on this issue now. 馃槃
This may be a trivial thing, but I am unable to figure out how to test out the changes i have made to brew/Library/Homebrew/cmd/search.rb locally on my system.
Prior to this, while working on issues related to a formula, all I did was reinstall the formula from the shallow clone of my repository. How do you suggest I test out the changes in this case? cc - @MikeMcQuaid @SMillerDev
Hi @vidusheeamoli, thanks for your contributions so far! :rocket:
You'll find brew's source code - this repository - cloned into brew --repo on your system. So cd $(brew --repo) will put you into /usr/local/Homebrew, then you can make changes to Library/Homebrew/cmd/search.rb and run brew search as you normally would. Then you'll see your changes immediately.
For making changes to formulae, it's the same approach but with cd $(brew --repo homebrew/core) - you end up in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core.
Let me know how you get on. If you have any further questions about this I'm happy to help!
Thank you @issyl0! I'll get started right away 馃槃
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Am I mistaken , or is this closed by https://github.com/Homebrew/brew/pull/7094?
@vitorgalvao
Here is what brew search looks like now:
brew search #default, only lists formulae
brew search --formulae #lists only formulae
brew search --casks #lists only casks
brew search <arg> #lists both formulae and casks
brew search --formulae <arg> #lists only formulae
brew search --casks <arg> #lists only casks
If this looks good, then I think this issue can be closed. :)
Yup, fixed by @vidusheeamoli, great work!
Most helpful comment
馃憤 this sounds good to me.