src/ez/line.bend checks
raw source on the hub · import 0x886223f5c47e4983fe57d887c034bc7f/src/ez/line.bend as Line
ez/line: the command line, taken apart before any command runs. spec is
the program, command names what a matched path runs, and line decides
how a parse ends: a command runs, help is shown, or the line is misused.
All of it is pure, so the status a line exits with before any command runs
is a law (EZ-OUT-1); ez/main.bend prints and exits as line and status
say, and runs the command a line names, whose own end decides the rest.
2 imports
import Base import 0xcab8a7a189cec2b51e8db0484f69c593/main.bend as Shake
Types
type Sub source · line 11 · raw
Data
a subcommand
CInitSub
CAddSub
CRemoveSub
CLockSub
CFetchSub
CCheckSub
CBuildSub
CRunSub
CPublishSub
CTestSub
CProveSub
CDoctorSub
CToolSyncSub
CToolRunSub
CToolInstallSub
CToolUpgradeSub
CHelpSub
type Line source · line 153 · raw
Data
a command runs, with what the line bound for it; help is shown, on stdout; or the line is misused, and says so on stderr
Runs@sub:Sub -> @matched:0xcab8a7a189cec2b51e8db0484f69c593/main.Matched -> Line
Shows@text:String -> Line
Misuse@text:String -> Line
type Status source · line 201 · raw
Data
the status a line exits with, when it is decided here, or the command's own end (EZ-OUT-1)
Exits@code:U32 -> Status
EndsStatus
Definitions
def spec source · line 31 · raw
0xcab8a7a189cec2b51e8db0484f69c593/main.Cli
the program: every command, and the flags and positionals it binds
def command source · line 105 · raw
@+name:String -> Sub
a subcommand by its path, the words joined with /. A path that names no
command, the empty one of a bare ez or a group such as tool, is CHelp.
def is.help source · line 127 · raw
@sub:Sub -> Bool
whether a subcommand is the one that names no command
def path source · line 135 · raw
@matched:0xcab8a7a189cec2b51e8db0484f69c593/main.Matched -> String
the path a match names, its words joined with /
def leaf source · line 141 · raw
@+matched:0xcab8a7a189cec2b51e8db0484f69c593/main.Matched -> 0xcab8a7a189cec2b51e8db0484f69c593/main.Matched
the Matched of the command the path names, whose bindings are the ones the
line made for that command (SHAKE-GET-2: at(m, path_of(m)) follows the
selected path). A None here would be a Matched parse never answers.
def get source · line 145 · raw
@found:0xcab8a7a189cec2b51e8db0484f69c593/main.Matched -> @+name:String -> String
the value the command bound to name, or "" when it bound none
def line.err source · line 161 · raw
@help:Maybe<&2, List<&2, String>> -> @+app:0xcab8a7a189cec2b51e8db0484f69c593/main.Cli -> @err:0xcab8a7a189cec2b51e8db0484f69c593/main.ParseErr -> Line
a line Shake would not parse: a request for help, whose path Shake has
already checked word by word (SHAKE-PARSE-8: help bogus fails as
Unexpected, not as a request for help), or a usage error
def line.group source · line 172 · raw
@bare:Bool -> @+app:0xcab8a7a189cec2b51e8db0484f69c593/main.Cli -> @+matched:0xcab8a7a189cec2b51e8db0484f69c593/main.Matched -> Line
a path that names no command: a bare ez is help, as a bare cargo is,
and a bare group such as ez tool is a line that did not say which of its
commands to run, as cargo report with no command is, so its help goes to
stderr and the line fails
def line.run source · line 180 · raw
@help:Bool -> @sub:Sub -> @+app:0xcab8a7a189cec2b51e8db0484f69c593/main.Cli -> @+matched:0xcab8a7a189cec2b51e8db0484f69c593/main.Matched -> Line
a line Shake parsed: the command its path names runs, or it names none
def line source · line 188 · raw
@+app:0xcab8a7a189cec2b51e8db0484f69c593/main.Cli -> @parsed:Result<&2, &2, 0xcab8a7a189cec2b51e8db0484f69c593/main.ParseErr, 0xcab8a7a189cec2b51e8db0484f69c593/main.Matched> -> Line
how a line ends, from what Shake made of it
def status source · line 206 · raw
@how:Line -> Status
help exits 0, a misused line 1, and a command that runs ends as it ends