src/check.bend checks
raw source on the hub · import shake@0.5.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 guarantee of SPEC.md's parse rows 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
RestNotLast@path:List<&2, String> -> @name:String -> SpecErr
SameName@path:List<&2, String> -> @name:String -> SpecErr
SameShort@path:List<&2, String> -> @short:String -> SpecErr
SameLong@path:List<&2, String> -> @long:String -> SpecErr
SameSub@path:List<&2, String> -> @name:String -> SpecErr
HelpSub@path:List<&2, String> -> SpecErr
DefaultNotChoice@path:List<&2, String> -> @name:String -> @value:String -> SpecErr
RequiredAfterOptional@path:List<&2, String> -> @name:String -> SpecErr
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, 0x1b64bb5828eb2210a4a61a1ba480631a/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, 0x1b64bb5828eb2210a4a61a1ba480631a/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, 0x1b64bb5828eb2210a4a61a1ba480631a/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, 0x1b64bb5828eb2210a4a61a1ba480631a/src/cli.Arg> -> @subs:List<&2, 0x1b64bb5828eb2210a4a61a1ba480631a/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, 0x1b64bb5828eb2210a4a61a1ba480631a/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:0x1b64bb5828eb2210a4a61a1ba480631a/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