156 Commits

Author SHA1 Message Date
Rylan Polster
c0df920660
Parse named args from formula stubs 2025-08-25 00:34:09 -04:00
Mike McQuaid
3bbff84ff1
Merge pull request #20525 from Homebrew/utils_output
Move `o*` output methods to `Utils::Output`
2025-08-22 09:10:29 +00:00
Ruoyu Zhong
33a2f410af
cli/parser: convert switch env values to boolean
Since switch values are boolean, we should be returning the environment
variable's presence instead of its string value.

Fixes #20531.
2025-08-22 01:59:54 +08:00
Mike McQuaid
a1f112f3fe
Move o* output methods to Utils::Output
This reduces the surface area of our `Kernel` monkeypatch and removes
the need to `include Kernel` in a bunch of modules.

While we're here, also move `Kernel#require?` to `Homebrew` and fully
scope the calls to it.
2025-08-20 19:20:19 +01:00
Douglas Eichelberger
157992be17
Enable strict typing in Cask::Audit 2025-07-30 12:43:32 -07:00
Eric Knibbe
3dc9e88542
parser: show related env var in switch description 2025-06-03 13:57:42 -04:00
Douglas Eichelberger
8253e89eea
Improve readability of disabled command message 2025-05-10 09:23:34 -07:00
Mike McQuaid
c9a7b62b1d
Homebrew 4.5 deprecations/disables/removals
The usual cycle of deprecating, disabling, and removing things in
Homebrew major/minor releases.
2025-04-22 17:15:23 +01:00
Douglas Eichelberger
659f993dab Avoid exposing table 2024-12-08 10:28:10 -08:00
Douglas Eichelberger
6d19b84ef1 Fix args validation 2024-12-08 10:28:10 -08:00
Douglas Eichelberger
fef1211c19 Use method result table
foo
2024-12-08 10:28:10 -08:00
Douglas Eichelberger
3ea76b8498 Avoid re-defining #formula? 2024-12-08 10:28:09 -08:00
Douglas Eichelberger
3a4243742f Remove OpenStruct from CLI::Args 2024-12-08 10:27:49 -08:00
Douglas Eichelberger
06aaeafa4f Minor CLI code improvements 2024-12-07 08:09:15 -08:00
Douglas Eichelberger
9a2b386a52 Remove unsafe references from CLI and Formulary code 2024-12-06 11:06:27 -08:00
Mike McQuaid
94416e82f0
Add new odeprecated, odisabled, remove disabled code.
Prepare the usual deprecation cycle for Homebrew 4.4.0.
2024-09-24 10:15:34 +01:00
Douglas Eichelberger
eeb31d3050 Fix violations 2024-09-20 11:07:00 -07:00
Douglas Eichelberger
7cd329c116 Makes args readable 2024-09-19 10:58:53 -07:00
Douglas Eichelberger
7acddd7eb2 Remove unused processed option element 2024-08-19 13:19:56 -07:00
Douglas Eichelberger
3943ff1406 Strict type Homebrew::CLI::Args 2024-08-18 20:30:58 -07:00
Douglas Eichelberger
becb84fc65
Update Library/Homebrew/cli/parser.rb
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2024-08-13 13:03:48 -07:00
Douglas Eichelberger
f7e17713a2 Update message, as there is a replacement 2024-08-10 11:55:43 -07:00
Douglas Eichelberger
d554c11b4c Add docs link 2024-08-10 11:20:53 -07:00
Douglas Eichelberger
a0a7f355d5 Create dummy brew cmd 2024-08-10 11:20:53 -07:00
Douglas Eichelberger
4fd659797f Deprecate invoking commands in the old style 2024-08-10 11:20:47 -07:00
Mike McQuaid
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Mike McQuaid
9586473f77
brew style --fix 2024-05-17 14:25:54 +09:00
Douglas Eichelberger
7bfa552702 Individually namespace args for each command 2024-04-21 16:51:31 -07:00
Douglas Eichelberger
11720132bb cleanup 2024-04-21 14:34:55 -07:00
Mike McQuaid
ed6f3064e5 cli/parser: improve mutable constant comment. 2024-04-21 14:16:26 -07:00
Douglas Eichelberger
98d36c30c5 Apply suggestions from code review
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2024-04-21 14:16:25 -07:00
Douglas Eichelberger
cb71938fff Enable strict typing in CLI::Parser 2024-04-21 14:16:25 -07:00
Douglas Eichelberger
c59d9fa833 Prefer numbered block params over proc conversion, cont'd 2024-04-08 09:47:27 -07:00
Douglas Eichelberger
bf9ebccecd Handle dashed commands 2024-03-20 10:36:19 -07:00
Douglas Eichelberger
6b19bc5535 Style cleanup 2024-03-20 10:36:19 -07:00
Douglas Eichelberger
d873881c47 Port Homebrew::DevCmd::BumpFormulaPr 2024-03-20 10:25:17 -07:00
Douglas Eichelberger
cae62e0175 Update Command API 2024-03-20 10:16:17 -07:00
Douglas Eichelberger
625206b0bd Avoid duplicating global options 2024-03-15 16:30:09 -07:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Douglas Eichelberger
90996e1997 git grep -lE '\(\&[A-Za-z._]+method\(:' | xargs gsed -i -E 's|\(\&([A-Za-z._]+)public_method\(:([a-z?_]+)\)\)| { \1\2(_1) }|g' 2024-03-03 18:55:32 -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
Dave Nicolson
31f09f8d30 Replace “QuickLook” with “Quick Look” 2024-02-03 23:54:04 +01:00
Douglas Eichelberger
08e12b2383 Remove ActiveSupport Array access core extensions 2024-01-19 13:34:52 -08:00
Bo Anderson
5692c8ecbf
Fix style violations under newer RuboCop 2023-12-14 05:47:12 +00:00
Markus Reiter
0a4d10ba89
Deprecate --new-formula/--new-cask options. 2023-12-06 16:18:26 +01:00
apainintheneck
779d90082d cli/parser: rescue formula specification errors
This came up recently where an outdated formula definition
caused the program to crash with an ambiguous message when
a user wanted to upgrade a cask instead. Catching these errors
allows them to get handled later on improving error messages
and defaults. Now if the only formula with the given name is
invalid it will default to using the cask unless --formula is
specified.

- https://github.com/Homebrew/brew/issues/16123
2023-10-21 17:15:26 -07:00
Mike McQuaid
abeab3e6c6
cli/parser: tweak style.
Co-authored-by: Kevin <apainintheneck@gmail.com>
2023-10-08 19:12:43 +01:00
Eric Knibbe
d3959727d6
cli/parser: depopulate commands' args lists 2023-10-07 23:52:34 -04:00
Mike McQuaid
58f8832a7e
cli/parser: check env var directly if there's no EnvConfig method.
Before this change, external commands, whether official or not, cannot
use the `env:` DSL for `Homebrew::CLI::Parser` without adding their
environment variable to `Homebrew::EnvConfig`.

Instead, if the method is not defined, check the environment variable
directly. This allows `env:` to be used as expected and allows
simplifying some (new) code in e.g. `brew bundle`.
2023-09-27 12:28:24 +01:00
Mike McQuaid
7da934f7e2
Deprecate/disable/delete code.
The next release after this is merged will be 4.1.0.

Co-authored-by: Markus Reiter <me@reitermark.us>
2023-07-06 16:56:20 +01:00