72 Commits

Author SHA1 Message Date
apainintheneck
2d47193d22 cmd/untap: move module methods back into the cmd
The extra module was their to facilitate testing but now that
everything is properly namespaced and each command is an instance
we can just move the methods into the command. Since it's an
instance now we don't need to be as careful about caching either.
2024-04-03 22:06:19 -07:00
Douglas Eichelberger
48f4adad33 Port Homebrew::Cmd::Untap 2024-04-01 11:50:25 -07:00
apainintheneck
ff495a2e44 untap: add new module to make these refactored methods easier to test 2024-03-10 22:33:33 -07:00
apainintheneck
46a32f90c4 cmd/untap: refactor logic into methods to facilitate testing 2024-03-10 22:33:33 -07:00
apainintheneck
819af3cbdd cmd/untap: fix installed formula & cask check
This wasn't working before for a few reasons.

1. It never got past the installed name check because the
installed name sets had short names and the tap names were
long names including the tap namespace too. Now we just trim the
long name before comparing it to the installed name set.

Before:

```
["name"].include?("tap/full/name") # always false
```

After:

```
["name"].include("tap/full/name".split("/").last) # sometimes true
```

2. The names we were trying to load formulae and casks with
were incorrect.

Before:

```
tap = Tap.fetch("homebrew/cask-versions")
token = "homebrew/cask-versions/token"

cask = Cask::CaskLoader.load("#{tap}/#{token}")
```

After:

```
token = "homebrew/cask-versions/token"
cask = CaskCaskLoader.load(token)
```
2024-03-10 22:33:33 -07: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
Mike McQuaid
fbd3d4e48a
cmd/untap: be more careful about formula tap.
`Formula#any_version_installed?` doesn't consider taps so we need to
manually check the tabs from the kegs instead.

See https://github.com/Homebrew/brew/pull/16330#issuecomment-1854007492
onwards for relevant discussion.
2023-12-13 15:24:37 +00:00
Mike McQuaid
beb9799265
cmd/untap: fix untapping syntax failure.
If an installed cask is invalid on attempting an untap: it will
prevent untapping that cask.

Fix this in two ways: one more specific to `untap` and one more
generally to other commands too:
- specific: only read the actual formulae/casks from the tap we're
  untapping instead of all of those that are installed
- general: rescue more exceptions in `Cask::Caskroom.casks` (like we
  already do for `Formula.installed`
2023-12-13 13:54:37 +00:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Bo Anderson
e86a8c2477
Move HOMEBREW_NO_INSTALL_FROM_API defaults to shell 2023-02-24 21:53:08 +00:00
Rylan Polster
6db19212c6
Fix brew untap with HOMEBREW_INSTALL_FROM_API 2021-10-28 17:13:34 -04:00
Rylan Polster
0b8032d421
Document HOMEBREW_INSTALL_FROM_API 2021-10-22 12:37:57 -04:00
Rylan Polster
5d536d66fc
Rename HOMEBREW_JSON_CORE to HOMEBREW_INSTALL_FROM_API 2021-08-27 00:24:15 -04:00
Rylan Polster
60203afdd5
Merge env variables into HOMEBREW_JSON_CORE 2021-06-18 12:10:26 -04:00
Rylan Polster
1d516b628b
Use #present? and #blank? to check env variable 2021-06-18 12:07:34 -04:00
Rylan Polster
2760d981d3
Allow for homebrew/core to be untapped 2021-06-17 14:18:43 -04:00
Dawid Dziurla
a90fb27adb
untap: add missing --force switch 2021-02-04 18:36:32 +01:00
Rylan Polster
ecfad29347
tap: write untapped setting only on manual untap 2021-01-21 08:42:22 -05:00
Rylan Polster
d1f3e39b7b
Update commands to generate usage banner 2021-01-18 21:20:11 -05:00
Dawid Dziurla
332372469f
cmd: indicate multiple named args in usage banner 2021-01-15 13:04:00 +01:00
Rylan Polster
da811373d3 Add named_args DSL for commands 2021-01-13 17:09:42 -05:00
Dawid Dziurla
6248ab7725
untap: add --force switch
Co-authored-by: Eric Knibbe <enk3@outlook.com>
2020-12-10 22:37:45 +01:00
Mike McQuaid
026381d359
Revert "untap: add --force switch" 2020-12-09 13:01:35 +00:00
Dawid Dziurla
e397f388f3
untap: add --force switch
Co-authored-by: Eric Knibbe <enk3@outlook.com>
2020-12-09 12:03:40 +01:00
Dawid Dziurla
5f9140f8a8
untap: add --force switch
Co-authored-by: Eric Knibbe <enk3@outlook.com>
2020-12-06 17:16:02 +01:00
Markus Reiter
5be4c9b5e0 Upgrade typed sigils. 2020-11-25 17:04:19 +01:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
d4c2ffd705 Refactor CLI::Parser. 2020-07-31 15:07:17 +02:00
Mike McQuaid
a7fe0ed847
cmd: use more and cleanup new args APIs. 2020-03-05 09:40:15 +00:00
EricFromCanada
2f7c3afeb8 cmd: improve wording of messages, spacing 2019-12-15 00:04:45 -05:00
EricFromCanada
b4303cd983 manpages: fix command & option descriptions 2019-08-20 09:03:33 -04:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
e40b171127
Rename cli_parser to cli/parser. 2019-04-17 22:16:50 +09:00
Mike McQuaid
6cb7a00f2d
cmd: remove --help headers and tweak docs. 2019-01-30 21:39:28 +00:00
Gautham Goli
e70df22acd
untap: Use CLI::Parser to parse args 2018-11-11 18:35:55 +05:30
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Mike McQuaid
9fca172d03 Fix HOMEBREW_RUBY_WARNINGS="-w"
Fix various circular requirements, method redefinitions, etc.
2018-04-07 20:28:56 +01:00
Markus Reiter
0ab750bf24 Use module_function for commands. 2016-10-02 00:24:47 +02:00
Max Nordlund
fa1fd70a37 Add all the top level comments 2016-04-10 22:59:25 +02:00
Xu Cheng
fa9a9ff5be tap-(un)pin/untap: better error message
Closes Homebrew/homebrew#49904.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-04-02 21:51:36 +08:00
Xu Cheng
1e487edd21 tap various commands: use tap name method.
Instead of hard coded `Homebrew/homebrew`
2016-03-07 19:43:46 +08:00
Xu Cheng
28f3dae8cd rename CoreFormulaRepository to CoreTap
Core tap will be separated from core code in the near future.
It makes sense to rename it to CoreTap.
2016-03-07 19:43:46 +08:00
Xu Cheng
2c25303949 remove unnecessary tap_args
It's now handled by Tap.fetch
2015-12-09 16:56:59 +08:00
Xu Cheng
e97610b916 add Tap#install and Tap#uninstall 2015-11-09 15:34:20 +08:00
Xu Cheng
3b520cf195 cache taps
There are plenty of IO operations inside Tap object, and it will be more
when implementing formula alias reverse look up(e.g. list all of alias
names for a formula). So let's cache them.

Some benchmark:

$ time brew info $(brew ruby -e 'puts Formula.tap_names') > /dev/null
Before: 6.40s user 2.42s system 96% cpu 9.134 total
After: 4.75s user 0.77s system 97% cpu 5.637 total

Closes Homebrew/homebrew#44377.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-09-30 16:25:30 +08:00
Dan Martinez
8374374168 Improve description searching and add a cache.
Closes Homebrew/homebrew#42281.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-09-08 15:23:37 +01:00
CNA-Bld
1a82b2133e implement pinning of taps 2015-08-10 12:17:25 +01:00
BrewTestBot
13d544e11e Core files style updates.
Closes Homebrew/homebrew#42354.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-03 13:22:35 +01:00
Xu Cheng
b88cb13718 add TapUnavailableError 2015-06-14 21:28:36 +08:00