Mike McQuaid 4c012a41c6
Port brew help (without arguments) to Bash
This provides a decent speedup:
```
$ hyperfine 'git checkout master; brew help' 'git checkout help_bash; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     506.4 ms ±  50.9 ms    [User: 223.7 ms, System: 99.9 ms]
  Range (min … max):   454.6 ms … 634.1 ms    10 runs

Benchmark 2: git checkout help_bash; brew help
  Time (mean ± σ):     109.5 ms ±  57.1 ms    [User: 1
```

and compares favourably to `pip3 help`:
```
$ hyperfine 'brew help' 'pip3 help'
Benchmark 1: brew help
  Time (mean ± σ):      72.9 ms ±  15.9 ms    [User: 4.9 ms, System: 6.3 ms]
  Range (min … max):    53.6 ms … 126.6 ms    31 runs

Benchmark 2: pip3 help
  Time (mean ± σ):     171.5 ms ±   6.1 ms    [User: 131.6 ms, System: 24.7 ms]
  Range (min … max):   164.2 ms … 189.3 ms    15 runs

Summary
  brew help ran
    2.35 ± 0.52 times faster than pip3 help
```
2024-07-14 11:54:05 -04:00

49 lines
1.1 KiB
Bash

#: * `help`
#:
#: Outputs the usage instructions for `brew`.
#:
# NOTE: Keep the length of vanilla `--help` less than 25 lines!
# This is because the default Terminal height is 25 lines. Scrolling sucks
# and concision is important. If more help is needed we should start
# specialising help like the gem command does.
# NOTE: Keep lines less than 80 characters! Wrapping is just not cricket.
HOMEBREW_HELP_MESSAGE=$(
cat <<'EOS'
Example usage:
brew search TEXT|/REGEX/
brew info [FORMULA|CASK...]
brew install FORMULA|CASK...
brew update
brew upgrade [FORMULA|CASK...]
brew uninstall FORMULA|CASK...
brew list [FORMULA|CASK...]
Troubleshooting:
brew config
brew doctor
brew install --verbose --debug FORMULA|CASK
Contributing:
brew create URL [--no-fetch]
brew edit [FORMULA|CASK...]
Further help:
brew commands
brew help [COMMAND]
man brew
https://docs.brew.sh
EOS
)
homebrew-help() {
if [[ -z "$*" ]]
then
echo "${HOMEBREW_HELP_MESSAGE}" >&2
exit 1
fi
echo "${HOMEBREW_HELP_MESSAGE}"
return 0
}