47 Commits

Author SHA1 Message Date
Todd Schulman
8bd3b48258 fix(search.rb): fix regex regression in search
Fixes a regression in `brew search` which prevented using a regex for
the search pattern after strict typing was added to `formula.rb` in
commit a81239e. Now performs fuzzy search only if input is a string.

Closes #19397
2025-02-28 09:33:32 -05:00
Daeho Ro
47e70ab3ea allow @ and + characters for search 2024-09-17 12:43:28 +09:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Ryan Rotter
99486c8107 Use API for description searches
Both `brew search --desc` and `brew desc --search` use API for cask and
formula searches unless `--eval-all` or `HOMEBREW_EVAL_ALL` set.
Description searches do not use the description cache or eval any
formulas/casks.

- With `--eval-all`, description search reverts to the old behavior.
- Warn if description search exludes any formulae/casks (because
  `--eval-all` not set).
- Enforce `--eval-all` requirement if NO_INSTALL_FROM_API set.
2024-06-30 23:05:29 -04:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
apainintheneck
ca5dfadfaf search: update logic to reflect changes to CoreCaskTap#cask_tokens
It was possible for the cask tokens to be included twice in the
cask_tokens array. This was cancelled out by the fact that we |=
the arrays together but still it was unnecessary work that is best
avoided and makes the code harder to reason about. This is simpler.
2024-03-09 19:38:43 -08:00
Issy Long
f4218a6316
Fix RuboCop Performance/MapCompact offenses
- Rename an iterator variable since it would make the line too long.
2024-02-25 22:59:59 +00:00
Douglas Eichelberger
09c679e75f Refactor module_function to reduce rbi need 2023-04-17 10:37:59 -07:00
Bo Anderson
3697825784
search: remove remote searching 2023-04-12 13:16:19 +01:00
apainintheneck
c073cf901a search: show results by platform
This means that formulas that are only available on one
OS should only show up in the search results for the platform.
2023-03-27 20:04:57 -07:00
Douglas Eichelberger
de90ddf07c Fix DescriptionCacheStore searching 2023-03-09 19:10:38 -08:00
Douglas Eichelberger
1195772b02 Refactor Searchable into Homebrew::Search 2023-03-07 09:08:54 -08:00
Bo Anderson
e86a8c2477
Move HOMEBREW_NO_INSTALL_FROM_API defaults to shell 2023-02-24 21:53:08 +00:00
Rylan Polster
cc615ef7fb
Fix brew search for HOMEBREW_INSTALL_FROM_API 2023-01-23 13:32:54 -05:00
apainintheneck
f41089fff4 Use module_function in search.rb 2022-12-19 19:27:48 -08:00
apainintheneck
47b3f6fe6e Stop including/extending search.rb
- Instead use class methods.
- This is better than use it as a mixin
  when only a small number of methods are
  used in each class or module.
- It also allows us to conditionally
  require it in `brew install`.
- Removed unused search require in descriptions.rb.
2022-12-17 11:08:13 -08:00
apainintheneck
0ae416d0ee Refactor Search#search_descriptions
- Move cask logic back into method from extend/os and check
  whether to display it based on args since formula?
  is passed by default on Linux now
- Use #search_descriptions in `brew desc` instead of
  duplicating logic
- Remove need for extend/os/search
2022-12-17 10:03:41 -08:00
apainintheneck
ba664fa1b4 Move Search#search_casks out of extend/os
This doesn't need to be isolated anymore because
there is a check for the formula and cask args
and formula is passed by default on Linux now.
2022-12-17 09:27:33 -08:00
apainintheneck
cb64bc4df3 Move pkg type logic into search_name
Now the search_name method takes the command line
args and only returns package types that line up
with those args.

That means it will only return casks if casks are valid
and same with formulae.
2022-12-13 22:50:00 -08:00
apainintheneck
daa87fa10f Add specific examples to install cmd
- provide specific install instructions
  when a cask/formula doesn't exist
  and we search for similar ones
- print and exit early if a named formula that
  was removed recently has the same name
- exit early if the tap is specified because
  we don't get good search results
2022-12-12 21:04:59 -08:00
apainintheneck
a481729ade Show casks in install not found output
- Move `search_names` and `print_missing_formula_help` out of `cmd/search.rb` to `search.rb`
- Change to using those functions in `cmd/install.rb` when a formula or cask doesn't exist
2022-12-10 13:02:38 -08:00
Mike McQuaid
639cb25c60
description*: fix argument handling of eval_all.
Fixes #14231.
2022-12-08 09:57:12 +00:00
EricFromCanada
2fdc70c3bf
desc, search: also search cask descriptions 2022-03-30 11:23:55 -04:00
hyuraku
3ccb1f6328 search by desc with formula-cask option 2021-07-25 20:10:35 +09:00
nthumann
da347ca1aa
Fix duplicate formulae in search results 2021-06-28 00:22:55 +02:00
Alexander Bayandin
d455ca9377
search: add fuzzy search results 2021-06-22 18:06:52 +01:00
nandahkrishna
56e0c3d9e8
Update GitHub API usage 2021-02-15 22:38:27 +05:30
nandahkrishna
8e5451df2f
style: use parentheses for assignment in conditions 2021-02-12 18:33:37 +05:30
Jonathan Chang
500908ee6f rubocop: fix Lint/NoReturnInBeginEndBlocks 2020-11-10 23:28:31 +11:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
4718b8e434 Document Search. 2020-08-26 03:13:59 +02:00
Mike McQuaid
3381cbf5c7
Use Homebrew::EnvConfig. 2020-04-07 09:58:26 +01:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
825d908d16
search: fix RuboCop style violation. 2019-04-04 19:49:06 +01:00
Mike McQuaid
737b84b54b
brew style --fix fixes. 2018-11-02 17:29:23 +00:00
Mike McQuaid
fe6b78a3f3
Use cache_store for descriptions
This makes use of both the existing interfaces and could use the
existing cache file but we'll create a new one and cleanup the old one
to avoid issues and use a more consistent name.
2018-10-13 08:22:52 -07:00
Markus Reiter
b265d870ed Allow searching Casks by name. 2018-06-18 16:23:36 +02:00
Markus Reiter
b21430b13c Use extend/os pattern. 2018-06-18 16:23:36 +02:00
Markus Reiter
da193d2f7e Merge brew cask search into brew search. 2018-06-18 16:23:35 +02:00
Markus Reiter
cb7f25ceb8 Refactor brew cask search. 2018-06-07 18:42:30 +02:00
Markus Reiter
535babee97 Refactor search_formulae. 2018-06-07 17:57:26 +02:00
Markus Reiter
cc93997fb7 Refactor search_taps. 2018-06-07 14:02:31 +02:00
Markus Reiter
717032d86d Use Searchable module. 2018-06-07 14:02:31 +02:00
Markus Reiter
6fcc5d14de Simplify strings for search. 2018-06-07 13:50:10 +02:00
Markus Reiter
99e3135bfa Make query_regexp ignore special symbols. 2018-06-07 13:50:10 +02:00
Markus Reiter
cff42a8a8c Show remote Casks, even if available locally … for now. 2018-06-07 13:50:10 +02:00
Markus Reiter
dd8370a9fa Move shared search logic into Homebrew::Search module. 2018-06-07 13:50:10 +02:00