main.bend checks
raw source on the hub · import 0xebdf72b20ad527103f6efc0d2aa8f1ec/main.bend as Main
shake: CLI argument parser for Bend 2. parse reads argv against a Cli;
help writes usage for a command path. A compiled binary's runtime keeps
--help (and --threads, --gpu, --gpu-build) and strips them; help
is the subcommand that prints usage. A -- ends option parsing.
1 import
import Base
Types
type ArgKind source · line 8 · raw
Data
a flag, a valued option, or a positional
FlagArgKind
OptArgKind
PosArgKind
type Arg source · line 14 · raw
Data
one argument: name is the binding key; short/long are the CLI spellings
Arg@name:String -> @short:Maybe<&2, String> -> @long:Maybe<&2, String> -> @kind:ArgKind -> @help:String -> @required:Bool -> @default:Maybe<&2, String> -> @choices:List<&2, String> -> Arg
type Sub source · line 27 · raw
Data
a nested command
Sub@name:String -> @about:String -> @args:List<&2, Arg> -> @subcommands:List<&2, Sub> -> Sub
type Cli source · line 36 · raw
Data
the program: name, about, optional version, top-level args and commands
Cli@name:String -> @about:String -> @version:Maybe<&2, String> -> @args:List<&2, Arg> -> @subcommands:List<&2, Sub> -> Cli
type Bind source · line 46 · raw
Data
one bound name and its text
Bind@name:String -> @value:String -> Bind
type Matched source · line 50 · raw
Data
a successful parse: selected command path and the bindings
Matched@+path:List<&2, String> -> @+binds:List<&2, Bind> -> Matched
type ParseErr source · line 54 · raw
Data
a failed parse. NeedHelp is help / help <path>
UnknownFlag@flag:String -> ParseErr
Missing@name:String -> ParseErr
BadValue@name:String -> @value:String -> ParseErr
NeedHelp@path:List<&2, String> -> ParseErr
Unexpected@arg:String -> ParseErr
type Mode source · line 62 · raw
Data
how the next token is read
FreeMode
Need@name:String -> Mode
HelpMode
Dead@err:ParseErr -> Mode
type St source · line 69 · raw
Data
the walker: current spec, accumulated specs, selected path, bindings
St@mode:Mode -> @args:List<&2, Arg> -> @specs:List<&2, Arg> -> @subs:List<&2, Sub> -> @path:List<&2, String> -> @binds:List<&2, Bind> -> @pos:List<&2, Arg> -> @raw:Bool -> @seen:Bool -> St
type How source · line 83 · raw
Data
the page a help walk has reached
How@bin:String -> @about:String -> @version:Maybe<&2, String> -> @args:List<&2, Arg> -> @subs:List<&2, Sub> -> @usage:String -> How
Definitions
def app source · line 94 · raw
@+name:String -> @+about:String -> @version:Maybe<&2, String> -> @args:List<&2, Arg> -> @subs:List<&2, Sub> -> Cli
a program spec
def sub source · line 99 · raw
@+name:String -> @+about:String -> @args:List<&2, Arg> -> @subs:List<&2, Sub> -> Sub
a nested command
def flag source · line 104 · raw
@+name:String -> @short:Maybe<&2, String> -> @long:Maybe<&2, String> -> @+help:String -> Arg
a boolean flag
def opt source · line 109 · raw
@+name:String -> @short:Maybe<&2, String> -> @long:Maybe<&2, String> -> @+help:String -> @required:Bool -> @default:Maybe<&2, String> -> @choices:List<&2, String> -> Arg
a valued option
def pos source · line 115 · raw
@+name:String -> @+help:String -> @required:Bool -> @default:Maybe<&2, String> -> @choices:List<&2, String> -> Arg
a positional
def help.max source · line 120 · raw
@+a:Nat -> @+b:Nat -> Nat
the larger of two Nats
def help.spaces source · line 124 · raw
@n:Nat -> String
n spaces
def help.pad source · line 132 · raw
@+s:String -> @n:Nat -> String
s padded on the right to width n
def text.of source · line 136 · raw
@m:Maybe<&2, String> -> @+d:String -> String
a Maybe string's text, or the default
def looks_flag source · line 140 · raw
@+s:String -> Bool
whether a string is a flag token (- alone is not)
def from.rev source · line 144 · raw
@cs:List<&2, Char> -> String
chars reversed into a string
def cut_eq.pick source · line 148 · raw
@eq:Bool -> @acc:List<&2, Char> -> @t:List<&2, Char> -> @rest:Pair(String, Maybe<&2, String>) -> Pair(String, Maybe<&2, String>)
name and an optional =value, once the next char is known
def cut_eq.chr source · line 157 · raw
@+c:Char -> @t:List<&2, Char> -> @acc:List<&2, Char> -> @rest:Pair(String, Maybe<&2, String>) -> Pair(String, Maybe<&2, String>)
one char of a name=value cut
def cut_eq.go source · line 162 · raw
@cs:List<&2, Char> -> @+acc:List<&2, Char> -> Pair(String, Maybe<&2, String>)
name and an optional =value from the body after --
def cut_eq source · line 171 · raw
@s:String -> Pair(String, Maybe<&2, String>)
name and an optional =value
def short_of.go source · line 175 · raw
@+name:String -> @+rest:String -> Pair(String, Maybe<&2, String>)
a short spelling and a glued value
def short_of source · line 179 · raw
@+s:String -> Pair(String, Maybe<&2, String>)
the short name and optional glued value of the body after -
def by_long.hit source · line 183 · raw
@a:Arg -> @+name:String -> Bool
whether this Arg's long spelling is name
def by_long.at source · line 188 · raw
@hit:Bool -> @h:Arg -> @rest:Maybe<&2, Arg> -> Maybe<&2, Arg>
this Arg when the long spelling matches, else the rest
def by_long source · line 196 · raw
@args:List<&2, Arg> -> @+name:String -> Maybe<&2, Arg>
the Arg with this long spelling, if any
def by_short.hit source · line 204 · raw
@a:Arg -> @+name:String -> Bool
whether this Arg's short spelling is name
def by_short.at source · line 209 · raw
@hit:Bool -> @h:Arg -> @rest:Maybe<&2, Arg> -> Maybe<&2, Arg>
this Arg when the short spelling matches, else the rest
def by_short source · line 217 · raw
@args:List<&2, Arg> -> @+name:String -> Maybe<&2, Arg>
the Arg with this short spelling, if any
def by_name.hit source · line 225 · raw
@a:Arg -> @+name:String -> Bool
whether this Arg's name is name
def by_name.at source · line 230 · raw
@hit:Bool -> @h:Arg -> @rest:Maybe<&2, Arg> -> Maybe<&2, Arg>
this Arg when the binding name matches, else the rest
def by_name source · line 238 · raw
@args:List<&2, Arg> -> @+name:String -> Maybe<&2, Arg>
the Arg with this binding name, if any
def find_sub.at source · line 246 · raw
@s:Sub -> @rest:Maybe<&2, Sub> -> @+name:String -> Maybe<&2, Sub>
this Sub when its name matches, else the rest
def find_sub source · line 251 · raw
@subs:List<&2, Sub> -> @+name:String -> Maybe<&2, Sub>
the Sub with this name, if any
def pos.is.kind source · line 259 · raw
@k:ArgKind -> Bool
whether this Arg is a positional
def pos.is source · line 269 · raw
@a:Arg -> Bool
whether this Arg is a positional
def pos_of.put source · line 274 · raw
@keep:Bool -> @h:Arg -> @rest:List<&2, Arg> -> List<&2, Arg>
this Arg kept when it is a positional
def pos_of source · line 282 · raw
@args:List<&2, Arg> -> List<&2, Arg>
the positionals of a spec, in order
def allowed.ok.at source · line 290 · raw
@hit:Bool -> @rest:Bool -> Bool
whether v is among the choices; an empty list accepts any value
def allowed.ok source · line 298 · raw
@cs:List<&2, String> -> @+v:String -> Bool
whether v is listed; the empty list answers no
def allowed source · line 306 · raw
@+cs:List<&2, String> -> @+v:String -> Bool
empty choices accept any value; otherwise v must be listed
def bound.hit source · line 310 · raw
@b:Bind -> @+name:String -> Bool
whether this bind's name is name
def bound.at source · line 315 · raw
@hit:Bool -> @rest:Bool -> Bool
True when the head matches, else the rest
def bound source · line 323 · raw
@bs:List<&2, Bind> -> @+name:String -> Bool
whether name is already bound
def get.bind.at source · line 331 · raw
@b:Bind -> @rest:String -> @+name:String -> String
this bind's value when the name matches, else the rest
def get.bind source · line 336 · raw
@bs:List<&2, Bind> -> @+name:String -> String
the value bound to name, or ""
def get source · line 344 · raw
@m:Matched -> @+name:String -> String
the value bound to name, or ""
def on source · line 349 · raw
@m:Matched -> @+name:String -> Bool
whether a flag named name was set
def path_of source · line 353 · raw
@m:Matched -> List<&2, String>
the selected command path
def parse.start source · line 358 · raw
@app:Cli -> St
the starting walker for a Cli
def parse.dead source · line 363 · raw
@e:ParseErr -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a failed walker that keeps the rest of the state
def parse.put source · line 369 · raw
@+name:String -> @+val:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a successful bind of name to val
def parse.choices source · line 375 · raw
@m:Maybe<&2, Arg> -> List<&2, String>
the choices of a found Arg, or none
def parse.take_choice source · line 384 · raw
@ok:Bool -> @+name:String -> @+val:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
bind name to val when the value is allowed
def parse.take_opt_val source · line 394 · raw
@+name:String -> @+val:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
bind an option that already has its value
def parse.take_flag source · line 401 · raw
@val:Maybe<&2, String> -> @+name:String -> @+orig:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a flag with no glued value is set; a glued value is unexpected
def parse.take_opt source · line 412 · raw
@val:Maybe<&2, String> -> @+name:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
an option: glued value now, or the next token
def parse.take_arg.kind source · line 422 · raw
@k:ArgKind -> @+name:String -> @val:Maybe<&2, String> -> @+orig:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
dispatch on the found Arg's kind
def parse.take_arg source · line 435 · raw
@found:Maybe<&2, Arg> -> @val:Maybe<&2, String> -> @+orig:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a found Arg, or an unknown flag
def parse.take_long.named source · line 448 · raw
@empty:Bool -> @+name:String -> @val:Maybe<&2, String> -> @+orig:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a long option with a name, or --=...
def parse.take_long.cut source · line 460 · raw
@nv:Pair(String, Maybe<&2, String>) -> @+orig:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a long option after the = cut
def parse.take_long source · line 469 · raw
@body:String -> @+orig:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a long option body after --
def parse.take_short.cut source · line 476 · raw
@nv:Pair(String, Maybe<&2, String>) -> @+orig:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a short option after the glued-value cut
def parse.take_short source · line 485 · raw
@body:String -> @+orig:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a short option body after -
def parse.take_pos source · line 492 · raw
@+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @pos:List<&2, Arg> -> @raw:Bool -> St
the next remaining positional, or an unexpected word
def parse.enter source · line 504 · raw
@s:Sub -> @+specs:List<&2, Arg> -> @+path:List<&2, String> -> @binds:List<&2, Bind> -> St
this Sub's spec becomes current; parent bindings stay
def parse.req.go source · line 512 · raw
@req:Bool -> @bare:Bool -> @+n:String -> Maybe<&2, String>
required and no default → Some{name}
def parse.req source · line 516 · raw
@a:Arg -> Maybe<&2, String>
a required Arg without a default, as a missing name
def parse.first_req.at source · line 521 · raw
@here:Maybe<&2, String> -> @rest:Maybe<&2, String> -> Maybe<&2, String>
this missing name, else the rest
def parse.first_req source · line 530 · raw
@pos:List<&2, Arg> -> Maybe<&2, String>
the first leftover required positional
def parse.enter_or source · line 538 · raw
@miss:Maybe<&2, String> -> @s:Sub -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a leftover required positional blocks entering a subcommand
def parse.word.go source · line 548 · raw
@found:Maybe<&2, Sub> -> @+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a found subcommand, or a positional
def parse.word source · line 559 · raw
@+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a word: a subcommand, or a positional
def parse.step.short.go source · line 566 · raw
@alone:Bool -> @+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+seen:Bool -> St
- as a word, or a short option
def parse.step.short source · line 577 · raw
@dash:Bool -> @+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+seen:Bool -> St
- alone is a positional; otherwise a short option
def parse.step.kind.go source · line 588 · raw
@long:Bool -> @dash:Bool -> @+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+seen:Bool -> St
--long first, then -s, then a word
def parse.step.kind source · line 599 · raw
@+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+seen:Bool -> St
a long option, a short option, or a word
def parse.step.help source · line 606 · raw
@hit:Bool -> @+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+seen:Bool -> St
help in command position collects the rest of argv as a path
def parse.step.end source · line 616 · raw
@end:Bool -> @+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+seen:Bool -> St
-- ends option parsing
def parse.step.raw source · line 627 · raw
@raw:Bool -> @+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+seen:Bool -> St
after --, every token is a positional
def parse.step.need source · line 638 · raw
@flag:Bool -> @+name:String -> @+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
a pending option value: a flag-shaped token is a missing value
def parse.step.mode source · line 648 · raw
@mode:Mode -> @+tok:String -> @+args:List<&2, Arg> -> @+specs:List<&2, Arg> -> @+subs:List<&2, Sub> -> @+path:List<&2, String> -> @+binds:List<&2, Bind> -> @+pos:List<&2, Arg> -> @+raw:Bool -> @+seen:Bool -> St
one token against the walker
def parse.step source · line 664 · raw
@+tok:String -> @st:St -> St
one token
def parse.walk source · line 669 · raw
@argv:List<&2, String> -> @st:St -> St
every token, in order
def fill.one source · line 677 · raw
@skip:Bool -> @+name:String -> @+val:String -> @rest:List<&2, Bind> -> List<&2, Bind>
a default value kept when the name is not already bound
def fill.arg.go source · line 686 · raw
@d:Maybe<&2, String> -> @+name:String -> @+binds:List<&2, Bind> -> List<&2, Bind>
a Some default is filled when unbound
def fill.arg source · line 695 · raw
@a:Arg -> @+binds:List<&2, Bind> -> List<&2, Bind>
this Arg's default, when it has one and is not bound
def fill.args source · line 700 · raw
@args:List<&2, Arg> -> @+binds:List<&2, Bind> -> List<&2, Bind>
defaults of every spec Arg
def miss.one source · line 708 · raw
@need:Bool -> @+name:String -> @rest:Maybe<&2, String> -> Maybe<&2, String>
a required name that is not bound
def miss.arg source · line 717 · raw
@a:Arg -> @+binds:List<&2, Bind> -> @rest:Maybe<&2, String> -> Maybe<&2, String>
whether this Arg is required and unbound
def miss.args source · line 723 · raw
@args:List<&2, Arg> -> @+binds:List<&2, Bind> -> Maybe<&2, String>
the first required name that is not bound
def parse.finish.miss source · line 731 · raw
@m:Maybe<&2, String> -> @path:List<&2, String> -> @binds:List<&2, Bind> -> Result<&2, &2, ParseErr, Matched>
a missing required name, or the matched result
def parse.finish.ok source · line 740 · raw
@specs:List<&2, Arg> -> @path:List<&2, String> -> @+binds:List<&2, Bind> -> Result<&2, &2, ParseErr, Matched>
required names after defaults
def parse.finish.mode source · line 745 · raw
@mode:Mode -> @+specs:List<&2, Arg> -> @path:List<&2, String> -> @+binds:List<&2, Bind> -> Result<&2, &2, ParseErr, Matched>
a finished walker: help, a pending value, an error, or defaults + required
def parse.finish source · line 758 · raw
@st:St -> Result<&2, &2, ParseErr, Matched>
the walker, finished
def parse source · line 763 · raw
@app:Cli -> @argv:List<&2, String> -> Result<&2, &2, ParseErr, Matched>
argv against a Cli
def show.err source · line 767 · raw
@e:ParseErr -> String
a ParseErr as a short tag
def show.bind source · line 781 · raw
@b:Bind -> @+rest:String -> String
one bind as name=value
def show.binds source · line 786 · raw
@bs:List<&2, Bind> -> String
the bindings as name=value words
def show.matched source · line 794 · raw
@m:Matched -> String
a Matched as path | binds
def show source · line 799 · raw
@r:Result<&2, &2, ParseErr, Matched> -> String
a parse result as a single line
def help.label.kind source · line 807 · raw
@k:ArgKind -> @+name:String -> @+label:String -> String
the short/long label of an option, plus a metavar for Opt
def help.label.pair source · line 817 · raw
@+short:String -> @+long:String -> String
-s, --long or one of them
def help.label source · line 824 · raw
@a:Arg -> String
the usage label of an option
def help.extra.go source · line 829 · raw
@+d:String -> @+cs:List<&2, String> -> String
extras after the help string: default and choices
def help.extra source · line 839 · raw
@a:Arg -> String
extras after the help string
def help.opt_line source · line 844 · raw
@+a:Arg -> @w:Nat -> String
one option line, given the label width
def help.opt_width source · line 849 · raw
@args:List<&2, Arg> -> @n:Nat -> Nat
the max option-label width
def help.opt_lines.at source · line 857 · raw
@skip:Bool -> @h:Arg -> @rest:String -> @w:Nat -> String
a non-positional option line
def help.opt_lines source · line 865 · raw
@args:List<&2, Arg> -> @+w:Nat -> String
option lines, skipping positionals
def help.opts.go source · line 873 · raw
@+body:String -> String
wrap option lines in a heading
def help.opts source · line 877 · raw
@+args:List<&2, Arg> -> String
the Options block, or empty when there are none
def help.sub_name source · line 881 · raw
@s:Sub -> String
a command's name
def help.sub_about source · line 886 · raw
@s:Sub -> String
a command's about
def help.cmd_width source · line 891 · raw
@subs:List<&2, Sub> -> @n:Nat -> Nat
max command-name width, including help
def help.cmd_line source · line 899 · raw
@+name:String -> @+about:String -> @w:Nat -> String
one command line
def help.cmd_lines source · line 903 · raw
@subs:List<&2, Sub> -> @+w:Nat -> String
command lines, then help
def help.cmds source · line 912 · raw
@+subs:List<&2, Sub> -> String
the Commands block
def help.pos.one source · line 916 · raw
@a:Arg -> String
a positional in a usage line: <NAME> or [NAME]
def help.pos.at source · line 922 · raw
@keep:Bool -> @h:Arg -> @rest:String -> String
this positional's hint, else the rest
def help.pos source · line 930 · raw
@args:List<&2, Arg> -> String
every positional in a usage line
def help.opts_hint.go source · line 938 · raw
@has:Bool -> String
the bracketed options word when the spec has a flag or option
def help.has_opt.at source · line 942 · raw
@is_pos:Bool -> @rest:Bool -> Bool
True when this Arg is a flag or option, else the rest
def help.has_opt source · line 950 · raw
@args:List<&2, Arg> -> Bool
whether any Arg is not a positional
def help.opts_hint source · line 958 · raw
@args:List<&2, Arg> -> String
the options hint when needed
def help.cmd_hint source · line 962 · raw
@+subs:List<&2, Sub> -> String
[COMMAND] when there are subcommands
def help.usage source · line 966 · raw
@+name:String -> @+args:List<&2, Arg> -> @+subs:List<&2, Sub> -> String
Usage: name ...
def title.go source · line 971 · raw
@+name:String -> @v:Maybe<&2, String> -> String
name or name version
def help.page source · line 979 · raw
@+title:String -> @+about:String -> @+usage:String -> @+args:List<&2, Arg> -> @+subs:List<&2, Sub> -> String
one help page
def help.step.go source · line 985 · raw
@found:Maybe<&2, Sub> -> @+bin:String -> @+about:String -> @version:Maybe<&2, String> -> @args:List<&2, Arg> -> @subs:List<&2, Sub> -> @+next:String -> @+usage:String -> How
a found child becomes the page; an unknown name stays
def help.step source · line 996 · raw
@how:How -> @+name:String -> How
one path segment against the current page
def help.go source · line 1002 · raw
@path:List<&2, String> -> @how:How -> String
the page at the end of a shrinking path
def help source · line 1012 · raw
@+app:Cli -> @path:List<&2, String> -> String
usage for path under app; an unknown segment shows the last found page
def err.wrap source · line 1017 · raw
@app:Cli -> @+msg:String -> String
a short error with the root usage line
def err_text source · line 1023 · raw
@+app:Cli -> @e:ParseErr -> String
error text; NeedHelp is empty (the caller prints help)