- A friend got an error message when trying to use `brew extract` and it
wasn't immediately obvious to me why. The usage banner only mentioned
the "formula" argument, which they'd provided. This improves the error
message when there aren't enough arguments so that others have a
chance of figuring out how to use this command without having to look
at the code for `extract_args`.
Before:
```
➜ brew extract --version='1.4' libftdi
Usage: brew extract [--version=] [--force] formula ...
[...]
Error: Invalid usage: this command requires a formula argument
```
After:
```
➜ brew extract --version='1.4' libftdi
Usage: brew extract [options] formula tap
[...]
Error: Invalid usage: This command requires at least 2 named arguments.
```
- I don't like the "at least 2" phrasing here but that's a dive into the
arg parsing code that I don't have time for right now. An alternative
was `named_args [:formula, :destination_tap]`, but that gave the error
message "requires formula or destination_tap" which wasn't great
either. I also tried `min: 2, max: 2` and that was the same "at least
2" message.
issue was raised in #9139 for upgrade/reinstall --cask and was then
closed by #10284. Issue is that #10284 only actually fixed the reinstall
command, leaving behindd the 'upgrade' one which this now fixes.
Signed-off-by: António Meireles <antonio.meireles@reformi.st>
- rename to `homebrew_bootsnap.rb` to avoid conflicting with the
`bootsnap.rb` we need to `require`
- if the `require` fails: run bundler (until we vendor this gem)
> Bootsnap is a library that plugs into Ruby, with optional support
> for ActiveSupport and YAML, to optimize and cache expensive
> computations.
https://github.com/Shopify/bootsnap
For our case that translates to "repeated calls to `brew` have
reductions in the time spend `require`ing speeding up the process
boot time".
For example:
```
$ hyperfine --warmup=2 "unset HOMEBREW_BOOTSNAP; brew info wget" "export HOMEBREW_BOOTSNAP=1; brew info wget"
Benchmark #1: unset HOMEBREW_BOOTSNAP; brew info wget
Time (mean ± σ): 2.417 s ± 0.032 s [User: 659.0 ms, System: 855.5 ms]
Range (min … max): 2.382 s … 2.464 s 10 runs
Benchmark #2: export HOMEBREW_BOOTSNAP=1; brew info wget
Time (mean ± σ): 1.862 s ± 0.064 s [User: 425.3 ms, System: 566.8 ms]
Range (min … max): 1.736 s … 1.952 s 10 runs
Summary
'export HOMEBREW_BOOTSNAP=1; brew info wget' ran
1.30 ± 0.05 times faster than 'unset HOMEBREW_BOOTSNAP; brew info wget'
```