38 Commits

Author SHA1 Message Date
Markus Reiter
3e8709e4da
Use full terminal height for concurrent output. 2025-02-01 17:58:54 +01:00
Issy Long
f3a68b616c
Early return in Tty#color? for nil @stream 2025-01-22 22:01:34 +00:00
Issy Long
975a707b3c
Bump some utils/ files to Sorbet typed: strict 2025-01-22 22:01:34 +00:00
Markus Reiter
9fd4c97fac
Add method for moving cursor up and to the beginning. 2024-09-04 22:54:29 +02:00
Markus Reiter
984cde114a
Move escape codes to Tty. 2024-09-04 22:54:28 +02:00
Markus Reiter
0cafa83f8a
Simplify Tty methods. 2024-09-04 22:54:26 +02:00
Markus Reiter
a114575663
Fix wrong terminal size. 2024-09-04 22:54:25 +02:00
Markus Reiter
6434533ff5
Remove Whirly and show concurrent downloads. 2024-09-04 22:54:24 +02: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
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
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
c76170a456
Hide #to_s in docs. 2024-04-26 14:04:55 +02:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Issy Long
1295904986
sorbet: Autogenerate the RBI file for utils/tty.rb
- Sort of. It's not via Parlour, because I read the docs and all it says
  about dynamically generating things is "of course it's better to do
  that", no examples. I tried my best, but Bo's work on `attr.rb` was
  mind-boggling.
- Instead, let's add a simple but functional generator script that I
  actually understand, as an alternative to maintaining these RBI files
  for dynamic methods manually, so that we can get rid of some use of
  `srb rbi hidden-definitions` since that's deprecated.
- TODO: Run this script as part of `brew typecheck --update` so it gets
  updated with all the other RBI files periodically.
- Follow up to PR 14651.
2023-03-06 21:46:04 +00:00
Mike McQuaid
e95ce6967a
brew style --fix 2023-02-24 13:50:07 +00:00
Markus Reiter
7348185347 Reorder global. 2020-11-30 00:00:02 +01:00
Markus Reiter
61b79318ed Move include Kernel into .rbi files again and split up existing .rbi files. 2020-10-10 19:10:58 +02:00
Markus Reiter
fc7a34585f Inline type annotations for Tty. 2020-10-10 15:49:18 +02:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
nandahkrishna
56a8f8f99d
livecheck: fix TTY output for progress bar 2020-09-18 02:41:25 +05:30
nandahkrishna
cf293d0ef5
livecheck: progress bar for JSON output
Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
Co-authored-by: Dustin Rodrigues <dust.rod@gmail.com>
2020-09-18 02:40:51 +05:30
nandahkrishna
c1909e80b4
utils/tty: fix TTY handling for stderr 2020-09-17 04:18:13 +05:30
Markus Reiter
d8eb508500 Document Tty. 2020-08-26 03:13:58 +02:00
Mike McQuaid
3381cbf5c7
Use Homebrew::EnvConfig. 2020-04-07 09:58:26 +01:00
Markus Reiter
9df563f25f Add Tty::color?. 2019-10-04 23:39:25 +02:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
d64429a736
rubocop: enable Style/IfUnlessModifier. 2019-02-21 12:55:49 +00:00
Mike McQuaid
737b84b54b
brew style --fix fixes. 2018-11-02 17:29:23 +00:00
Markus Reiter
c4d418e126 Use ActiveSupport’s #second. 2018-10-07 23:10:56 +02:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Markus Reiter
9db17ab5bc Allow forcing colored output. 2018-08-02 16:03:44 +02:00
Markus Reiter
13d9305fad Cache Tty.width, since it is used heavily because of ohai. 2018-06-15 13:56:08 +02:00
lukertty
f308aa4800
Tty.width: use tput cols when stty size returns 0;
bin/brew: add 'COLUMNS' and 'LINES' to env variables

Signed-off-by: lukertty <lukertty@gmail.com>
2018-05-30 12:29:24 +08:00
joshua stein
7388acb86e Tty: if HOMEBREW_NO_COLOR env var is present, disable color
bin/brew will recognize NO_COLOR variable and copy it to
HOMEBREW_NO_COLOR
2018-02-12 14:19:25 -06:00
Mike McQuaid
2cf2c020ba tty: handle non-tty stdin.
When stdin is not a tty then the message `stty: stdin isn't a terminal`
will be produced. Silence this message and fall back to `tput` when it
fails and default to 80 if we get no results at all.

Follow-up from #2714.
2017-06-07 06:57:50 +01:00
Enrico Ghirardi
a9c83f14a7
Use stty instead of tput to get terminal width
Fixes https://github.com/Homebrew/brew/issues/2707
2017-06-02 17:00:52 +02:00
Markus Reiter
6d8ee395fa Refactor Tty. 2016-10-01 20:00:49 +02:00