Skip to main content

Module goods

Module goods 

Source
Expand description

zx “goods”: small helpers for scripts (sleep, retry, spinner, …).

Constants§

SPINNER_FRAMES
Frames drawn by spinner.

Functions§

echo
Print the arguments joined by spaces followed by a newline (zx echo).
echo_line
The line echo would print (without the trailing newline).
exp_backoff
Exponential backoff delays: min(delay * 2^n, max) for n = 0, 1, 2, …
exp_backoff_default
exp_backoff with zx’s defaults (max = 60s, delay = 100ms).
glob
Expand a glob pattern into sorted paths (zx glob, subset: *, ?, [...] and **). Unreadable entries are skipped.
glob_in
Expand a glob pattern relative to cwd, returning paths relative to it.
retry
Call f until it succeeds, at most count times, without delays.
retry_with_backoff
Like retry, taking the delay after each failure from delays (for example exp_backoff). An exhausted iterator means no delay.
retry_with_delay
Like retry, sleeping delay between attempts.
sleep
Pause for duration (zx sleep).
sleep_for
Pause for a zx duration string such as "100ms" or "1s".
spinner
Run fut while showing a spinner titled title on stderr (zx spinner). Verbose logging is disabled for the duration of fut.
spinner_enabled
Whether spinner would draw anything: stderr must be a terminal, CI unset and the current scope not quiet.
tempdir
Create (like mkdir -p) and return a directory in the system temp dir. prefix defaults to zx-<random id>.
tempfile
Create a temp file and return its path (zx tempfile).
which
Locate an executable on PATH (zx which).