~/bend-docscommunity

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

raw source on the hub · import ezx@1.15.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.

16 imports
import Base
import snap@1.4.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/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 42 · raw

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

the first line, or nothing

def said.next source · line 54 · 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 62 · raw

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

the first line that is a commit, or ""

def line.abs source · line 70 · raw

@+line:String -> Bool

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

def said.abs source · line 74 · raw

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

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

def said.when source · line 82 · raw

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

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

def said.head source · line 90 · raw

@+out:String -> String

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

def said.top source · line 94 · raw

@+out:String -> String

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

def located source · line 100 · raw

@+abs:String -> IO(0x54c6454e798d1d497bdd6d0af3a8ac92/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 110 · raw

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

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

def locate source · line 118 · raw

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

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

def answer source · line 124 · raw

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

one question answered

def answer.all source · line 138 · raw

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

every question answered

def more source · line 149 · raw

@world:0x54c6454e798d1d497bdd6d0af3a8ac92/src/tool/world.World -> @rs:List<&2, 0x54c6454e798d1d497bdd6d0af3a8ac92/src/tool/world.Reply> -> @us:List<&2, 0x54c6454e798d1d497bdd6d0af3a8ac92/src/lock/up.Reply> -> 0x54c6454e798d1d497bdd6d0af3a8ac92/src/tool/world.World

the World with more answers in it

def exec.lay source · line 159 · raw

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

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

def compile.said source · line 170 · 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 180 · 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 192 · 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 203 · raw

@making:0x54c6454e798d1d497bdd6d0af3a8ac92/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 218 · raw

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

the lines a person is told, each on stderr

def link.after source · line 227 · raw

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

def exec.finish source · line 238 · raw

@fin:0x54c6454e798d1d497bdd6d0af3a8ac92/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 255 · raw

@+pl:0x54c6454e798d1d497bdd6d0af3a8ac92/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 267 · raw

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

def rounds source · line 280 · 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 286 · raw

@fuel:Nat -> @+world:0x54c6454e798d1d497bdd6d0af3a8ac92/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 294 · raw

@name:String -> IO(String)

a variable, "" when it is unset

def bend.is source · line 301 · 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 307 · raw

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

the variables the tool commands read

def go source · line 318 · raw

@act:0x54c6454e798d1d497bdd6d0af3a8ac92/src/tool/world.Act -> @+target:String -> @+want:String -> @+here:String -> @+vars:0x54c6454e798d1d497bdd6d0af3a8ac92/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 331 · raw

@act:0x54c6454e798d1d497bdd6d0af3a8ac92/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 341 · raw

@ns:List<&2, String> -> @+here:String -> @+vars:0x54c6454e798d1d497bdd6d0af3a8ac92/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 359 · raw

@+synced:0x54c6454e798d1d497bdd6d0af3a8ac92/src/tool/plan.Sync -> @+here:String -> @+vars:0x54c6454e798d1d497bdd6d0af3a8ac92/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 372 · raw

IO(Unit)

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