Class: Everywhere::UI::Status
- Inherits:
-
Object
- Object
- Everywhere::UI::Status
- Defined in:
- lib/everywhere/ui.rb
Overview
A single self-rewriting line for waits that produce no output — chiefly
every platform build, which can sit for many minutes while GitHub finds a
hosted macOS runner. Without it the CLI looks hung.
On a TTY it redraws in place with a spinner frame. When stdout is a pipe
(CI, | tee) carriage returns would pile up, so it degrades to one plain
line every HEADLESS_INTERVAL seconds. Callers MUST clear before writing
anything else — update tracks whether a line is currently on screen so
clear is cheap and idempotent.
Constant Summary collapse
- FRAMES =
%w[⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏].freeze
- HEADLESS_INTERVAL =
seconds between plain lines when not a TTY
30
Instance Method Summary collapse
-
#clear ⇒ Object
Wipe the current line so normal output lands on a clean row.
-
#initialize(io: $stdout) ⇒ Status
constructor
A new instance of Status.
- #update(text) ⇒ Object
Constructor Details
#initialize(io: $stdout) ⇒ Status
Returns a new instance of Status.
111 112 113 114 115 116 117 |
# File 'lib/everywhere/ui.rb', line 111 def initialize(io: $stdout) @io = io @tty = io.tty? && !ENV["NO_COLOR"] @frame = 0 @drawn = false @last_headless = nil end |
Instance Method Details
#clear ⇒ Object
Wipe the current line so normal output lands on a clean row. No-op when nothing is drawn (including the whole headless path).
132 133 134 135 136 137 138 |
# File 'lib/everywhere/ui.rb', line 132 def clear return unless @drawn @io.print("\r\e[2K") @io.flush @drawn = false end |