src/init/run.bend

ezx@1.10.0.0 · 20 lines · 0 definitions

1# init/run: the interpreter for `ez init`. It reads ez.toml, `.gitignore`,
2# the entry file and `src/lib.bend` into a World, asks the planner
3# (init/plan.bend) for the plan, and runs it with the lock's effect runner
4# (`Run.exec.plan`), which makes a file's directory before writing it and
5# exits 1 with the reason when the plan refuses. It decides nothing; that it
6# reads and executes faithfully is EZ-TRUST-2.
7import Base
8import ezx@1.10.0.0/src/io/file.bend as F
9import ezx@1.10.0.0/src/lock/run.bend as Run
10import ezx@1.10.0.0/src/init/plan.bend as IP
11
12# `ez init [name] [entry.bend] [--description TEXT]`
13def run(+name: String, +file: String, +desc: String) -> IO(Unit):
14  do IO<Unit>:
15    lib : String <- Run.bend.lib()
16    led : Maybe<&2, String> <- F.read(IP.toml())
17    ig : Maybe<&2, String> <- F.read(IP.ignore.file())
18    mn : Maybe<&2, String> <- F.read(IP.entry.or(file))
19    lb : Maybe<&2, String> <- F.read(IP.lib.file())
20    Run.exec.plan(lib, IP.plan(IP.World{name, file, desc, led, ig, mn, lb}))