src/fmt/run.bend relies on unsafe/foreign
raw source on the hub · import bolt@1.60.0.0/src/fmt/run.bend as Run
src/fmt/run: the interpreter for bolt fmt. It fills a World as the lint
does (src/lint.bend's loop: the same questions, answered by the same IO),
then carries out the plan src/fmt/plan.bend makes of it: each edit written
over its file, the lines printed, and the exit status. It decides nothing:
which files change and what they become are the planner's. That it writes
and prints faithfully is trusted, not proved, as with every interpreter
here; a file that cannot be opened or written ends the run at once, exit 1.
Effect: CPU event loop only.
5 imports
import Base import ../lint.bend as Lint import ../status.bend as Status import ../lint/world.bend as W import ./plan.bend as Fp
Definitions
def write.closed source · line 16 · raw
@r:Result<&1, &1, Pair(U32, String), Unit> -> @path:String -> IO(Unit)
a write that failed ends the run
def write.wrote source · line 24 · raw
@got:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> @path:String -> IO(Unit)
the file closed, then the write's result read
def write.opened source · line 31 · raw
@r:Result<&1, &1, Pair(U32, String), File> -> @path:String -> @text:String -> IO(Unit)
the text written to an opened file; one that did not open ends the run
def write source · line 41 · raw
@+path:String -> @text:String -> IO(Unit)
a file's text replaced
def write.all source · line 47 · raw
@es:List<&2, 0x10abb46b8df0409ba5fe4777735d49bf/src/fmt/plan.Edit> -> IO(Unit)
each edit written, in order
def exec source · line 58 · raw
@pl:0x10abb46b8df0409ba5fe4777735d49bf/src/fmt/plan.Plan -> IO(Unit)
a plan, carried out: its edits written, its lines printed, then its exit status
def run source · line 67 · raw
@check:Bool -> @paths:List<&2, String> -> IO(Unit)
bolt fmt over the files given, or the tree below; check: list the files
that would change and write none