37 Commits

Author SHA1 Message Date
Issy Long
28349370d3
Bump more files to Sorbet typed: strict 2024-10-06 20:04:42 +01: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
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
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Douglas Eichelberger
cb71938fff Enable strict typing in CLI::Parser 2024-04-21 14:16:25 -07:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Douglas Eichelberger
09c679e75f Refactor module_function to reduce rbi need 2023-04-17 10:37:59 -07:00
Rylan Polster
feb93167ad
Rename and fix Formatter:wrap to Formatter.format_help_text 2022-01-08 23:13:08 -05:00
Rylan Polster
86c241ab42
Make search and create arguments mandatory
Co-Authored-By: Nanda H Krishna <me@nandahkrishna.com>
2021-04-10 14:20:39 -04:00
Rylan Polster
f2064750f5
Add casks to default help text 2021-04-09 16:28:43 -04:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
86bd7bddbe
Merge pull request #8462 from reitermarkus/refactor-utils
Move `command_help_lines` into `Help` module.
2020-08-24 01:39:03 +02:00
Markus Reiter
0514e2dbba Move command_help_lines into Help module. 2020-08-24 00:46:33 +02:00
Markus Reiter
ba85c5316b Refactor and document Help. 2020-08-23 04:18:39 +02:00
Markus Reiter
6524802079 Pass remaining args to Help. 2020-08-06 16:13:14 +02:00
Markus Reiter
be2d19fe07 Refactor handling of formula options in CLI::Parser. 2020-07-31 17:46:54 +02:00
Markus Reiter
d4c2ffd705 Refactor CLI::Parser. 2020-07-31 15:07:17 +02:00
EricFromCanada
e62137133e docs: fix comment help output 2020-06-25 11:59:42 -04:00
Mike McQuaid
ca47992a6c
Fix rubocop-performance brew style. 2020-05-22 08:52:26 +01:00
Mike McQuaid
3381cbf5c7
Use Homebrew::EnvConfig. 2020-04-07 09:58:26 +01:00
Mike McQuaid
8a9dcad2c7
Move more command handling logic to commands.rb. 2020-02-02 17:05:45 +01:00
Mike McQuaid
eb87651341
Revert "Revert "help: print cli/parser help message if used"" 2020-02-02 16:36:59 +01:00
Mike McQuaid
2082379a61
Revert "help: print cli/parser help message if used" 2020-02-02 09:11:23 +01:00
Mike McQuaid
b03efb4356
Move shared man/help logic to cli/parser. 2020-02-01 19:05:03 +01:00
Mike McQuaid
cd423a2755
help: tweak structure/formatting. 2020-02-01 19:04:16 +01:00
Dawid Dziurla
e9274b3827
help: print cli/parser help message if used 2020-01-26 18:33:13 +01: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
EricFromCanada
560ccddb69 help: rewrap output to 80 columns
Accounts for paragraph breaks and option descriptions. Also fixes some help text nits.
2019-03-11 12:52:07 -04:00
Mike McQuaid
e095da4d01
rubocop: enable Layout/EmptyLineAfterGuardClause. 2019-02-21 12:55:49 +00:00
Mike McQuaid
4ace1af297
help: improve command --help output. 2019-01-30 21:39:29 +00:00
EricFromCanada
6b8724431f cli_parser: improve help text formatting
- reduce desc_line_length so `brew help` output fits in 80 columns
- support special formatting across line breaks
- support emphasis using asterisks
- add missing depends_on: tests
2018-10-12 13:38:14 -04:00
Gautham Goli
b5b988cbb1
help_spec: fix and generate help text in help.rb 2018-10-03 21:12:44 +05:30
Gautham Goli
7b0f27ca39
style: Fix style errors 2018-10-03 19:49:46 +05:30
Gautham Goli
604dfb4ae6
help: Let OptionParser generate help text for supported commands 2018-10-03 19:49:45 +05:30
Gautham Goli
df101dde84
Move --help handling of dev commands to help.rb 2018-10-03 19:20:26 +05:30
Andrew Janke
8b55cb5ecb Refactor commands to remove "require cmd/help" 2018-06-07 04:59:59 -04:00