~/bend-docscommunity

src/tool/plan.bend fails

raw source on the hub · import 0x886223f5c47e4983fe57d887c034bc7f/src/tool/plan.bend as Plan

tool/plan: ez tool run, install and upgrade as a pure planner, and ez tool sync as the list of installs it runs. The planner reads a World (tool/world.bend) and returns either the questions it still needs answered (step) or a Plan. The interpreter (tool/run.bend) loops on step, answering each question by IO, then executes the plan.

Before it asks anything the planner refuses what needs no answer: an install or upgrade with nowhere to link (EZ-TOOL-1), no cache root, a project ledger that does not parse, a target that names nothing or a cache slug that could leave the cache (EZ-TOOL-8), a name the ledger pins that the lock does not, or pins at no commit. Then it resolves the commit (EZ-TOOL-4): a [tools.*] pin is the lock's rev, url, entry and bin; a remote is what its HEAD names; a path is its clean HEAD, and a path with uncommitted or untracked changes, or one that is not the top of a checkout, is no commit (EZ-TOOL-3). Then the checkout: a remote's is cached per commit and read from there when its record says it finished, otherwise asked of git with every file's text; a path is read where it is. Then its ledger, which names the file built (EZ-TOOL-7) and the link, and a name that is not a TOML bare key is refused. A checkout with no ez.toml is a plain Bend repository: it builds main.bend, or the file --entry names, needs no lock, and is linked under that file's stem, or under the repository's name when the stem is main. A file to build that is not in the checkout is refused. Then the binary's record: the binary is reused only when it is there and its record is this commit, this file and this bend (EZ-TOOL-2). Every binary lives in a directory named by its record, so no two records share one, and a link made by an install is never rebuilt under it by a run of another commit or file.

The plan of a command that goes on, in order: the checkout laid under the cache when it was cloned, with its record written last; the lock fetched, for an ez project, and the binary built with its record, unless it is reused; then the program started, for run, or the link written, for install and upgrade. A refusal has no effect at all. The program is started only as the last thing, so its status is the command's (EZ-TOOL-5), and install and upgrade never start it (EZ-TOOL-6).

14 imports
import Base
import ./world.bend as TW
import ../lock/plan.bend as P
import ../lock/up.bend as Up
import ../ledger/manifest.bend as M
import ../toml/toml.bend as T
import ../pkg/pkg.bend as K
import ../pkg/path.bend as Path
import ../git/git.bend as Git
import ../ez/target.bend as Tgt
import ../ez/named.bend as Named
import ../ez/key.bend as Key
import ../share/say.bend as Say
import ../share/sha.bend as Sha