src/status.bend

bolt@1.22.0.0 · 14 lines · 0 definitions

1# src/status: a run's exit status. A run that found errors exits 1, so a
2# shell, the gate or an editor can tell without reading the output. `IO.die`
3# is what sets the code; its message goes to stderr and the findings are
4# already printed, so it is empty here (the runtime still ends it with a
5# newline: one blank line on stderr is the whole cost).
6import Base
7
8# exit 1 when the run found errors, else fall through (exit 0)
9def stop(bad: Bool) -> IO(Unit):  # noqa: L001 IO: exit status
10  match bad:
11    case True{}:
12      IO.die(Unit, 1, "")
13    case False{}:
14      IO.pure(Unit, Unit{})