~/bend-docscommunity

src/check.bend checks

raw source on the hub · import shake@0.9.0.0/src/check.bend as Check

shake/check: the ways a Cli can contradict itself, internal (main.bend exports check). parse does not call it: a program checks its spec once, and every parse guarantee (LAWS.bend) holds for a spec check passes.

2 imports
import Base
import ./cli.bend as C

Types

type SpecErr source · line 8 · raw

Data

one way a spec contradicts itself, at the command path where it does

type Want source · line 179 · raw

Data

how a program reads an argument: whether a flag is on (on), or its values (get, get_all)

type Read source · line 185 · raw

Data

one read a program makes: the command path, the argument's name, and how it reads it

type ReadErr source · line 189 · raw

Data

one read that does not fit the spec

Definitions

def one source · line 19 · raw

@hit:Bool -> @err:SpecErr -> List<&2, SpecErr>

one report when the flag is set, else none

def both source · line 27 · raw

@xs:List<&2, SpecErr> -> @ys:List<&2, SpecErr> -> List<&2, SpecErr>

two lists of reports, one after the other

def spelled.seen source · line 31 · raw

@sp:Maybe<&2, String> -> @+seen:List<&2, String> -> Bool

whether a spelling, when there is one, is among those already seen

def spelled.add source · line 39 · raw

@sp:Maybe<&2, String> -> @seen:List<&2, String> -> List<&2, String>

the spellings seen, with this one when there is one

def args.default source · line 47 · raw

@dflt:Maybe<&2, String> -> @+cs:List<&2, String> -> @+path:List<&2, String> -> @+name:String -> List<&2, SpecErr>

a default outside a nonempty choices list

def args.dups source · line 62 · raw

@args:List<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Arg> -> @+path:List<&2, String> -> @+names:List<&2, String> -> @+shorts:List<&2, String> -> @+longs:List<&2, String> -> List<&2, SpecErr>

each argument's name and spellings against the earlier ones', and its default against its choices

def pos.order source · line 83 · raw

@pos:List<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Arg> -> @+path:List<&2, String> -> @+opt_seen:Bool -> List<&2, SpecErr>

the positionals in order: a rest before the last, and a required one after an optional one

def subs.dups source · line 99 · raw

@subs:List<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Sub> -> @+path:List<&2, String> -> @+names:List<&2, String> -> List<&2, SpecErr>

each subcommand's name against the earlier ones', and against help

def cmd source · line 114 · raw

@+path:List<&2, String> -> @+args:List<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Arg> -> @subs:List<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Sub> -> List<&2, SpecErr>

one command's own reports

def pushed source · line 123 · raw

@name:String -> @back:List<&2, String> -> List<&2, String>

a name in front of a reversed path

def forest source · line 129 · raw

@subs:List<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Sub> -> @+back:List<&2, String> -> List<&2, SpecErr>

every subcommand's reports, each under its own path, depth first. The path is carried reversed, innermost name first, and read the right way round once per command

def check source · line 141 · raw

@app:0x64697f57fea19681b5fa4f87014ce63d/src/cli.Cli -> List<&2, SpecErr>

every way the spec contradicts itself: the root's reports, then each subcommand's

def at.pick source · line 146 · raw

@root:Bool -> @+path:List<&2, String> -> String

where a report is: the root, or a subcommand's path

def at source · line 154 · raw

@+path:List<&2, String> -> String

where a report is

def text source · line 158 · raw

@err:SpecErr -> String

a report as one line

def reads.one source · line 196 · raw

@hit:Bool -> @err:ReadErr -> List<&2, ReadErr>

a read report when the flag is set, else none

def reads.args source · line 204 · raw

@here:Maybe<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Sub> -> Maybe<&2, List<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Arg>>

the arguments of a found command

def reads.down source · line 213 · raw

@here:Maybe<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Sub> -> @+name:String -> Maybe<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Sub>

the subcommand named name of a found command

def reads.cmd source · line 223 · raw

@path:List<&2, String> -> @here:Maybe<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Sub> -> Maybe<&2, List<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Arg>>

the arguments of the command a path names below the command found, each name a subcommand of the command before it, or None

def reads.flag source · line 231 · raw

@kk:0x64697f57fea19681b5fa4f87014ce63d/src/cli.ArgKind -> Bool

whether an argument of this kind is a flag

def reads.want source · line 245 · raw

@want:Want -> @flag:Bool -> @+path:List<&2, String> -> @+name:String -> List<&2, ReadErr>

a read of an argument that is, or is not, a flag

def reads.arg source · line 253 · raw

@found:Maybe<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Arg> -> @want:Want -> @+path:List<&2, String> -> @+name:String -> List<&2, ReadErr>

a read of the argument found under its name, or of none

def reads.at source · line 262 · raw

@cmd:Maybe<&2, List<&2, 0x64697f57fea19681b5fa4f87014ce63d/src/cli.Arg>> -> @want:Want -> @+path:List<&2, String> -> @+name:String -> List<&2, ReadErr>

a read of the command a path names, or of none

def read source · line 275 · raw

@app:0x64697f57fea19681b5fa4f87014ce63d/src/cli.Cli -> @rr:Read -> List<&2, ReadErr>

what is wrong with one read, or nothing

def check_reads source · line 281 · raw

@+app:0x64697f57fea19681b5fa4f87014ce63d/src/cli.Cli -> @rs:List<&2, Read> -> List<&2, ReadErr>

what is wrong with each read, in order

def read.at source · line 289 · raw

@+path:List<&2, String> -> String

where a read report is

def read_text source · line 293 · raw

@err:ReadErr -> String

a read report as one line