import dataclasses import typing @dataclasses.dataclass(frozen=True) class Stop: """The entry point exits with code, printing reason.""" code: typing.Literal[0, 1, 2, 130] reason: str def needs_human(need: str, blocker: str) -> Stop: return Stop(2, f"the human is needed to {need}, but {blocker}") def needs_terminal(need: str, on_terminal: bool, driver: str) -> Stop | None: """driver is the entry point the human reruns, such as `do-epic`.""" if on_terminal: return None return needs_human(need, f"stdin or stdout is not a terminal; rerun {driver} on a terminal")