~/bend-docscommunity

src/tool/run.bend relies on unsafe/foreign

raw source on the hub · import ezx@1.18.0.0/src/tool/run.bend as Run

tool/run: the interpreter for ez tool run, install, upgrade and sync. It reads the directory it runs in, the variables, the bend on the PATH, and the project's ez.toml and ez.lock.toml into a World, then loops: it asks the planner (tool/plan.bend) what is still open, answers each question by IO, and adds the answers to the World, until nothing is left to ask. Then it runs the plan: the checkout laid, the binary built or reused, then the program started or the link written, and the plan's end. A git question is the lock interpreter's to answer (Run.answer.ups), a file is written by its Run.write, and the command exits with the status the planner gives the plan's end and the program's (TP.code), through Run.end.at. It decides nothing; that it reads and executes faithfully is trusted in ez/app.bend.

What it asks and builds on the way is captured, and a build's output is shown on stderr only when the build fails. The program alone is started on ez's own stdin, stdout and stderr (Pass.run), as cargo run hands the terminal to the program once the build is done.

sync asks the planner which pins to install (TP.sync) and installs each in turn as ez tool install <name> would.

17 imports
import Base
import snap@1.6.0.0/main.bend as R
import ../io/file.bend as F
import ../lock/run.bend as Run
import ../lock/plan.bend as LP
import ../lock/up.bend as Up
import ../git/git.bend as Git
import ../fetch/run.bend as FetchRun
import ../pkg/path.bend as P
import ../run/bend.bend as Bend
import ../share/cap.bend as Cap
import ../share/capped.bend as Capped
import ../share/say.bend as Say
import ../share/spin.bend as Spin
import ../share/pass.bend as Pass
import ./world.bend as TW
import ./plan.bend as TP

Definitions

def line0 source · line 43 · raw

@ls:List<&2, String> -> String

the first line, or nothing

def said.next source · line 55 · raw

@hit:Bool -> @+found:String -> @go:(@_:Unit -> String) -> String

the line found, or the walk gone on past a line of another shape

def said.rev source · line 63 · raw

@ls:List<&2, String> -> String

the first line that is a commit, or ""

def line.abs source · line 71 · raw

@+line:String -> Bool

a line that is an absolute path, as rev-parse --show-toplevel prints one

def said.abs source · line 75 · raw

@ls:List<&2, String> -> String

the first line that is an absolute path, or ""

def said.when source · line 83 · raw

@ok:Bool -> @read:(@_:Unit -> String) -> String

what a command that succeeded answered, read only then; "" when it failed

def said.head source · line 91 · raw

@+out:String -> String

the commit git rev-parse HEAD answered, or "" when it failed

def said.top source · line 95 · raw

@+out:String -> String

the top git rev-parse --show-toplevel answered, or "" when it failed

def located source · line 101 · raw

@+abs:String -> IO(0x2414c9622cab2353684d02a392804eb1/src/tool/world.Answer)

what git says of a path that has a real path: the top of its checkout, HEAD, and what git status names, untracked files included whatever the repository's own settings hide

def locate.real source · line 113 · raw

@ok:Bool -> @+path:String -> @+text:String -> IO(0x2414c9622cab2353684d02a392804eb1/src/tool/world.Answer)

a path that has a real path, or why it has none

def locate source · line 121 · raw

@+path:String -> IO(0x2414c9622cab2353684d02a392804eb1/src/tool/world.Answer)

a local path, made real, and what git says of it

def answer source · line 129 · raw

@ask:0x2414c9622cab2353684d02a392804eb1/src/tool/world.Ask -> IO(0x2414c9622cab2353684d02a392804eb1/src/tool/world.Answer)

one question answered

def answer.all source · line 143 · raw

@asks:List<&2, 0x2414c9622cab2353684d02a392804eb1/src/tool/world.Ask> -> IO(List<&2, 0x2414c9622cab2353684d02a392804eb1/src/tool/world.Reply>)

every question answered

def exec.lay source · line 158 · raw

@layout:0x2414c9622cab2353684d02a392804eb1/src/tool/plan.Lay -> IO(Unit)

a checkout laid: whatever was there removed, then every file, the record last

def compile.said source · line 169 · raw

@ok:Bool -> @+why:String -> @+text:String -> IO(Unit)

a build's output, shown on stderr when it failed, since stdout is the program's, as cargo keeps its own words off it

def compile source · line 179 · raw

@+lib:String -> @+file:String -> @+out:String -> IO(Unit)

bend <file> -o <out> under the memory cap, with the checkout's library

def exec.lib source · line 195 · raw

@fetch:Bool -> @+top:String -> @+lib:String -> IO(Unit)

the library a build reads: an ez project's lock fetched into it as ez fetch fetches one, with every relative path in it read from the checkout; a plain repository's made, for bend to fetch its hub imports into

def exec.make source · line 206 · raw

@making:0x2414c9622cab2353684d02a392804eb1/src/tool/plan.Make -> IO(Unit)

the binary: its library filled, the file built, the record written; or the one there reused

def tell source · line 221 · raw

@ls:List<&2, String> -> IO(Unit)

the lines a person is told, each on stderr

def link.after source · line 230 · raw

@ok:Bool -> @+at:String -> @+text:String -> @says:List<&2, String> -> IO(Unit)

def exec.finish source · line 241 · raw

@fin:0x2414c9622cab2353684d02a392804eb1/src/tool/plan.Finish -> IO(U32)

the program started with its words on ez's own stdin, stdout and stderr, or the link written, and the status the program exited with, 0 when none was started. What the program prints reaches the person as it prints it, and it reads what ez would have read.

def exec.plan source · line 258 · raw

@+pl:0x2414c9622cab2353684d02a392804eb1/src/tool/plan.Plan -> IO(Unit)

a plan, executed, and how it ends: with the status the planner gives its end and the program's status (TP.code, laws/ExitStatusSaysFailure.bend)

def loop.step source · line 270 · raw

@st:0x2414c9622cab2353684d02a392804eb1/src/tool/plan.Step -> @world:0x2414c9622cab2353684d02a392804eb1/src/tool/world.World -> @go:(@_:0x2414c9622cab2353684d02a392804eb1/src/tool/world.World -> IO(Unit)) -> IO(Unit)

def rounds source · line 283 · raw

Nat

the rounds the loop may take. The planner asks at most five rounds, so this is only a guard against a planner that keeps asking, and running out of it dies loudly.

def loop source · line 289 · raw

@fuel:Nat -> @+world:0x2414c9622cab2353684d02a392804eb1/src/tool/world.World -> IO(Unit)

the loop, under fuel. Every round adds an answer, since the planner never asks what the World answers already, and it asks at most five rounds, so the fuel is only a guard.

def var source · line 297 · raw

@name:String -> IO(String)

a variable, "" when it is unset

def bend.is source · line 304 · raw

IO(String)

the bend on the PATH, as its banner's first line. A bend that does not answer is "", and its build fails on its own.

def env source · line 310 · raw

IO(0x2414c9622cab2353684d02a392804eb1/src/tool/world.Env)

the variables the tool commands read

def go source · line 321 · raw

@act:0x2414c9622cab2353684d02a392804eb1/src/tool/world.Act -> @+target:String -> @+want:String -> @+here:String -> @+vars:0x2414c9622cab2353684d02a392804eb1/src/tool/world.Env -> @+bend:String -> @+led:Maybe<&2, String> -> @+lock:Maybe<&2, String> -> IO(Unit)

one target, run, installed or upgraded, over the project's ledger and lock, building the file want names when it names one

def run source · line 334 · raw

@act:0x2414c9622cab2353684d02a392804eb1/src/tool/world.Act -> @+target:String -> @+want:String -> IO(Unit)

ez tool run [--entry <file>] <target> [-- args…], install and upgrade

def sync.all source · line 344 · raw

@ns:List<&2, String> -> @+here:String -> @+vars:0x2414c9622cab2353684d02a392804eb1/src/tool/world.Env -> @+bend:String -> @+led:Maybe<&2, String> -> @+lock:Maybe<&2, String> -> IO(Unit)

every name a sync installs, in turn

def sync.go source · line 362 · raw

@+synced:0x2414c9622cab2353684d02a392804eb1/src/tool/plan.Sync -> @+here:String -> @+vars:0x2414c9622cab2353684d02a392804eb1/src/tool/world.Env -> @+bend:String -> @+led:Maybe<&2, String> -> @+lock:Maybe<&2, String> -> IO(Unit)

a sync's names installed in turn, none when it refuses, and then its end (TP.sync.outcome)

def sync source · line 375 · raw

IO(Unit)

ez tool sync: every pin the ledger names, installed at its lock rev