src/args.bend checks
raw source on the hub · import 0xde9bb08f7de298b03207fb5797ede9a5/src/args.bend as Args
src/args: bolt's command line, parsed by shake. bolt [lint] [file..],
bolt check file.., bolt lsp, bolt --version. A rest positional at the root (and on
lint / check) takes every leftover word, so bolt a.bend b.bend lints
those files. help is shake's usage page; --help stays with the Bend
runtime. A compiled binary does pass its arguments through; the runtime
takes only its own out of the line (--threads, --gpu, --gpu-build,
--help), wherever they stand, and -- hands even those to the program.
out is every decision the line makes, as data: what to print, where, and
the exit code, or the subcommand to run and its files. main only does it.
Only shake's interface (main.bend) is read here; what parse answers for a
given argv is shake's guarantee (SPEC.md BOLT-TRUST-8), not bolt's.
4 imports
import Base import 0x085b03c84ca37125e38dddede7b91e55/main.bend as Shake import ./version.bend as Ver import ./build_rev.bend as Rev
Types
type Cmd source · line 66 · raw
Data
a subcommand
CLintCmd
CCheckCmd
CLspCmd
type Stream source · line 77 · raw
Data
where a line that stops puts its text
LineStream
PageStream
ErrStream
type Out source · line 84 · raw
Data
what a parsed line does: print a text and exit with a code, or run a subcommand over files (which then exits as that command decides)
Stop@to:Stream -> @text:String -> @code:U32 -> Out
Go@cmd:Cmd -> @paths:List<&2, String> -> Out
Definitions
def widen source · line 19 · raw
@ss:List<&1, String> -> List<&2, String>
the line at the quantity the rest of bolt reads it at (IO.args gives each argument once)
def argv source · line 27 · raw
IO(List<&2, String>)
bolt's command line
def spec.files source · line 33 · raw
@+help:String -> 0x085b03c84ca37125e38dddede7b91e55/main.Arg
the files rest, optional, last among positionals
def version.at source · line 37 · raw
@+rel:String -> @+rev:String -> String
the release, with the short commit in parentheses when it is present
def version source · line 41 · raw
String
the release, and the short commit when the build has one
def spec source · line 45 · raw
0x085b03c84ca37125e38dddede7b91e55/main.Cli
bolt's program spec
def parse source · line 54 · raw
@av:List<&2, String> -> Result<&2, &2, 0x085b03c84ca37125e38dddede7b91e55/main.ParseErr, 0x085b03c84ca37125e38dddede7b91e55/main.Matched>
argv against bolt's spec
def help_text source · line 58 · raw
@path:List<&2, String> -> String
usage for a command path
def err_text source · line 62 · raw
@ee:0x085b03c84ca37125e38dddede7b91e55/main.ParseErr -> String
a parse error as the text the binary prints
def command source · line 72 · raw
@+name:String -> Cmd
a subcommand by its name; the empty name (no subcommand) is lint
def files.at source · line 91 · raw
@sel:Maybe<&2, 0x085b03c84ca37125e38dddede7b91e55/main.Matched> -> @+mm:0x085b03c84ca37125e38dddede7b91e55/main.Matched -> List<&2, String>
the files the selected command bound: each command keeps its own bindings, so they are read from the Matched at the end of the selected path, which is the root's own when no subcommand was selected
def files source · line 99 · raw
@+mm:0x085b03c84ca37125e38dddede7b91e55/main.Matched -> List<&2, String>
the files a successful parse bound, to the command it selected
def out.run source · line 103 · raw
@ask:Bool -> @+mm:0x085b03c84ca37125e38dddede7b91e55/main.Matched -> Out
a successful parse: the version, or the selected command and its files
def out.fail.at source · line 112 · raw
@asked:Maybe<&2, List<&2, String>> -> @+ee:0x085b03c84ca37125e38dddede7b91e55/main.ParseErr -> Out
a failed parse, given whether it asked for usage: that usage page, or the error
def out.fail source · line 120 · raw
@+ee:0x085b03c84ca37125e38dddede7b91e55/main.ParseErr -> Out
a failed parse: help text, or an error
def out.done source · line 124 · raw
@+mm:0x085b03c84ca37125e38dddede7b91e55/main.Matched -> Out
a successful parse, read once for the version flag
def out source · line 128 · raw
@rr:Result<&2, &2, 0x085b03c84ca37125e38dddede7b91e55/main.ParseErr, 0x085b03c84ca37125e38dddede7b91e55/main.Matched> -> Out
what a parse result does