~/bend-docscommunity

cli.bend checks

raw source on the hub · import cli@0.3.0.0/cli.bend as Cli

Purpose: pure command definitions, validation, and text rendering for Bend CLIs. Expected output: ALL PROOFS CHECK. Run: bend cli.bend --check-only

1 import
import Base

Types

type Style source · line 7 · raw

Data

type Segment source · line 30 · raw

Data

type StripState source · line 124 · raw

Data

type CodeRange source · line 167 · raw

Data

type CodeClass source · line 922 · raw

Data

What a code point can do in an emoji sequence (UTS #51): start a keycap (#, * and 0-9), be a pictograph, a skin tone, a ZWJ or VS16, or none.

type EmojiRun source · line 934 · raw

Data

Where width stands in an emoji sequence: outside one; after an emoji, with the code a skin tone or VS16 applies to, whether it counts 1 so far, and whether a ZWJ may join it; after such a ZWJ; or after a pictograph that a ZWJ joined, which adds nothing.

type WidthStep source · line 940 · raw

Data

type WrapState source · line 1068 · raw

Data

type ValueType source · line 1107 · raw

Data

type Item source · line 1124 · raw

Data

type Cmd source · line 1154 · raw

Data

type Problem source · line 1157 · raw

Data

type UsageKind source · line 1284 · raw

Data

type Usage source · line 1292 · raw

Data

type NameScan source · line 1296 · raw

Data

type PhScan source · line 1301 · raw

Data

PhOK's name is reversed: only a positional's name is read.

type LintItem source · line 1764 · raw

Data

An item as lint walks it: an Arg with its usage parsed once, a Sub with its children's too.

type Seen source · line 1830 · raw

Data

type DecimalState source · line 2002 · raw

Data

type Bad source · line 2075 · raw

Data

The first element of a value that fails to convert, and why.

type Src source · line 2439 · raw

Data

type Var source · line 2445 · raw

Data

type Host source · line 2448 · raw

Data

type Field source · line 2451 · raw

Data

type ScanEvent source · line 2454 · raw

Data

type ScanFault source · line 2463 · raw

Data

type ExternalArgs source · line 2476 · raw

Data

type ScanTrace source · line 2479 · raw

Data

type ParseResult source · line 2484 · raw

Data

type Early source · line 2492 · raw

Data

type Gather source · line 2498 · raw

Data

An arg's hits so far: values holds a repeated option's newest first, so each hit conses, and resolve_argv_gather puts them back in argv order.

type FieldBuild source · line 2501 · raw

Data

type EnvValue source · line 2505 · raw

Data

type ArgInfo source · line 2528 · raw

Data

type OptFound source · line 2532 · raw

Data

type SubFound source · line 2535 · raw

Data

type SubKey source · line 2539 · raw

Data

A subcommand a scope answers to, by name or alias.

type OptKey source · line 2543 · raw

Data

An option name a scope answers to, with the match it makes.

type SpecItem source · line 2547 · raw

Data

An item resolve walks: an Arg with its usage parsed once, or another item.

type Spec source · line 2554 · raw

Data

A scope with each usage parsed once: its option names (own, then global), the items resolve walks (global, then own), its positionals and subcommands, and the globals its subcommands inherit.

type Scope source · line 2560 · raw

Data

type ScanState source · line 2563 · raw

Data

type Tail source · line 2569 · raw

Data

Phases after which no token is an operand and -- is plain.

type Mode source · line 2574 · raw

Data

type SlotTraits source · line 2975 · raw

Data

What the slot that takes the next operand allows: rest(), values that start with "-", and as_f32().

type TokenClass source · line 3657 · raw

Data

How an open scan reads a token: a long token or a dash token (an option, a cluster of short options, or an operand a slot takes), or a word; "-" is a word.

type Fault source · line 4460 · raw

Data

type Matches source · line 4475 · raw

Data

type Form source · line 4522 · raw

Data

type Want source · line 4528 · raw

Data

What a reader asks of an arg; Q-static checks it against the spec.

type Program source · line 4839 · raw

Data

A program and its arguments, as Cli.program reads them.

type KeyStep source · line 4975 · raw

Data

How a route key's next word meets an item: not its subcommand, the subcommand of a built-in, the command the key ends at, or a command whose subcommands take the rest (§6.4).

type Term source · line 5266 · raw

Data

type Prescan source · line 5295 · raw

Data

The pre-scan of argv: the last --color value before --, "" for a bare --color before a hyphen token.

type View source · line 5437 · raw

Data

The command at the longest valid prefix of a path, with the globals it inherits, root first; stuck once a step names no subcommand.

type Row source · line 5593 · raw

Data

A help row: its left cell, whether it is an option with a short or a long-only option, and its right text.

type Section source · line 5596 · raw

Data

type Scored source · line 5950 · raw

Data

type Shell source · line 6419 · raw

Data

type Place source · line 6511 · raw

Data

A command on a visible path, in pre-order from the root: the words of its path below the root, its items, and the globals it inherits, root first.

type Comp source · line 6534 · raw

Data

What a value completes to: a word of the one_of list numbered list, a file, a directory, or nothing.

type Opt source · line 6542 · raw

Data

An option as a script offers it: its names, shorts first, its kind, its placeholder, what its value completes to, and its help on one line.

type Slot source · line 6547 · raw

Data

A positional slot, numbered from 1.

type Entry source · line 6552 · raw

Data

A visible subcommand: its name, its names with aliases, and its summary.

type Stop source · line 6741 · raw

Data

What a script needs at a place: its number, its words, its options in scope, own first, the built-ins, its visible subcommands, and its slots.

type Outcome source · line 7925 · raw

Data

type Linted source · line 8000 · raw

Data

A Cmd that passed lint, from linted: eval_linted skips the lint eval runs.

type Step source · line 8020 · raw

@-A:Type -> Type

type Ran source · line 8154 · raw

Data

What a run prints and how it ends: its exit status, its stdout text and its stderr text.

type Utf8Lead source · line 8203 · raw

Data

What a byte starts: no UTF-8 sequence (a continuation byte, C0, C1, F5 to FF, or a value past 255), or one with more continuation bytes, the code point bits the byte carries, and the least code point a sequence that long may hold, below which it is overlong.

type ArgChar source · line 8265 · raw

Data

A char decoded from argument bytes, and how many bytes after its first it took.

Definitions

def digit_at source · line 35 · raw

@digits:String -> @+d:U32 -> String

The char at index d of digits, as a string, and "" past its end: a lookup rather than a char code sum, so a proof sees each one's char.

def digit source · line 42 · raw

@d:U32 -> String

def num_text source · line 46 · raw

@+v:U32 -> String

v in decimal without leading zeros, for v up to 999.

def color_num source · line 55 · raw

@+n:U32 -> String

A 256-color index or an RGB part: n in decimal, and 255 when above it.

def rgb_text source · line 58 · raw

@r:U32 -> @g:U32 -> @b:U32 -> String

def style_code source · line 62 · raw

@style:Style -> String

def style_codes_tail source · line 86 · raw

@styles:List<&2, Style> -> String

def style_codes source · line 92 · raw

@styles:List<&2, Style> -> String

def paint source · line 98 · raw

@on:Bool -> @styles:List<&2, Style> -> @text:String -> String

def emit_go source · line 109 · raw

@segments:List<&2, Segment> -> @+on:Bool -> String

def emit source · line 118 · raw

@on:Bool -> @segments:List<&2, Segment> -> String

def sgr_body_char source · line 121 · raw

@+c:Char -> Bool

def strip_go source · line 129 · raw

@s:String -> @state:StripState -> String

def strip source · line 164 · raw

@s:String -> String

def contains_range source · line 170 · raw

@ranges:List<&2, CodeRange> -> @+code:U32 -> Bool

def unicode_is_wide source · line 180 · raw

@code:U32 -> Bool

Unicode 15.1 East Asian Wide and Fullwidth ranges, including reserved ranges. Source: https://www.unicode.org/Public/15.1.0/ucd/EastAsianWidth.txt

def unicode_is_zero_mark source · line 306 · raw

@code:U32 -> Bool

Unicode 15.1 nonspacing and enclosing mark ranges (Mn and Me). Source: https://www.unicode.org/Public/15.1.0/ucd/UnicodeData.txt

def unicode_is_pictographic source · line 655 · raw

@code:U32 -> Bool

Unicode 15.1 Extended_Pictographic ranges, including reserved ranges. Source: https://www.unicode.org/Public/15.1.0/ucd/emoji/emoji-data.txt

def unicode_takes_tone source · line 739 · raw

@code:U32 -> Bool

Unicode 15.1 Emoji_Modifier_Base ranges: the emoji a skin tone modifies. Source: https://www.unicode.org/Public/15.1.0/ucd/emoji/emoji-data.txt

def unicode_widens_with_vs16 source · line 787 · raw

@code:U32 -> Bool

Unicode 15.1 code points with an emoji presentation sequence (VS16) that are not East Asian Wide or Fullwidth, so VS16 widens them to 2. Sources: https://www.unicode.org/Public/15.1.0/ucd/emoji/emoji-variation-sequences.txt and https://www.unicode.org/Public/15.1.0/ucd/EastAsianWidth.txt

def code_width_by source · line 906 · raw

@small:Bool -> @+code:U32 -> Nat

A code point's own width: controls, marks, 200B-200F and tag characters (E0000-E007F) are 0, East Asian Wide and Fullwidth are 2, the rest 1.

def code_width source · line 917 · raw

@+code:U32 -> Nat

def keycap_base source · line 943 · raw

@+code:U32 -> Bool

def picto_class source · line 949 · raw

@may:Bool -> @+code:U32 -> CodeClass

may: whether code is in 203C-3299 or from 1F000, which hold every pictograph from 768 on.

def code_class_by source · line 956 · raw

@small:Bool -> @+code:U32 -> CodeClass

def code_class source · line 970 · raw

@+code:U32 -> CodeClass

def picto_alone source · line 973 · raw

@+wide:Bool -> @code:U32 -> WidthStep

def picto_step source · line 978 · raw

@run:EmojiRun -> @+code:U32 -> WidthStep

A pictograph after a ZWJ joins the sequence; any other starts an emoji.

def tone_on source · line 988 · raw

@takes:Bool -> @narrow:Bool -> @join:Bool -> @code:U32 -> WidthStep

A skin tone after an emoji that takes one widens it to 2; any other is 2 wide alone, as East Asian Wide.

def tone_on_joined source · line 995 · raw

@takes:Bool -> @code:U32 -> WidthStep

def tone_step source · line 1000 · raw

@run:EmojiRun -> @code:U32 -> WidthStep

def joiner_run source · line 1010 · raw

@run:EmojiRun -> EmojiRun

A ZWJ after an emoji that may join, or after a joined pictograph, waits for the next pictograph.

def vs16_widen source · line 1018 · raw

@widens:Bool -> @code:U32 -> @join:Bool -> WidthStep

def vs16_on source · line 1023 · raw

@narrow:Bool -> @+code:U32 -> @join:Bool -> WidthStep

def vs16_step source · line 1029 · raw

@run:EmojiRun -> WidthStep

VS16 widens a 1-wide emoji with an emoji presentation to 2, once.

def code_step source · line 1036 · raw

@cls:CodeClass -> @run:EmojiRun -> @code:U32 -> WidthStep

def width_go source · line 1046 · raw

@s:String -> @step:WidthStep -> @acc:Nat -> Nat

acc, plus the width of step, the last code point's, and of s after it.

def width source · line 1057 · raw

@s:String -> Nat

Display columns, as Rust's unicode-width 0.2 counts them: each code point's own width, except that an emoji sequence is one cell 2 wide. A pictograph that a ZWJ joins, a skin tone after an emoji that takes one, and tag characters add nothing; VS16 widens a 1-wide emoji to 2.

def leading_indent source · line 1060 · raw

@s:String -> String

def wrap_words source · line 1072 · raw

@words:List<&2, String> -> @state:WrapState -> String

def words source · line 1087 · raw

@s:String -> List<&2, String>

def wrap_line source · line 1091 · raw

@+line:String -> @cols:Nat -> String

def wrap_lines source · line 1097 · raw

@lines:List<&2, String> -> @+cols:Nat -> List<&2, String>

def wrap source · line 1104 · raw

@text:String -> @cols:Nat -> String

def type_name source · line 1115 · raw

@t:ValueType -> String

def cmd source · line 1174 · raw

@name:String -> @about:String -> @items:List<&2, Item> -> Cmd

def sub source · line 1177 · raw

@name:String -> @about:String -> @items:List<&2, Item> -> Item

def arg source · line 1180 · raw

@usage:String -> @help:String -> @items:List<&2, Item> -> Item

def version source · line 1183 · raw

@value:String -> Item

def usage_status source · line 1187 · raw

@code:U32 -> Item

A root's exit status for its usage errors in place of 2 (§8.7).

def alias source · line 1190 · raw

@name:String -> Item

def hidden source · line 1193 · raw

Item

def example source · line 1196 · raw

@line:String -> @what:String -> Item

def after source · line 1199 · raw

@text:String -> Item

def sub_optional source · line 1202 · raw

Item

def external source · line 1205 · raw

Item

def exclusive source · line 1208 · raw

@group:String -> Item

def need_one source · line 1211 · raw

@group:String -> Item

def id source · line 1214 · raw

@value:String -> Item

def required source · line 1217 · raw

Item

def default source · line 1220 · raw

@value:String -> Item

def env source · line 1223 · raw

@name:String -> Item

def global source · line 1226 · raw

Item

def heading source · line 1229 · raw

@title:String -> Item

def as_nat source · line 1232 · raw

Item

def as_u32 source · line 1235 · raw

Item

def as_f32 source · line 1238 · raw

Item

def as_bool source · line 1241 · raw

Item

def as_file source · line 1244 · raw

Item

def as_dir source · line 1247 · raw

Item

def one_of source · line 1250 · raw

@values:List<&2, String> -> Item

def delim source · line 1253 · raw

@sep:Char -> Item

def hyphen source · line 1256 · raw

Item

def rest source · line 1259 · raw

Item

def bare source · line 1262 · raw

@value:String -> Item

def conflicts source · line 1265 · raw

@target:String -> Item

def requires source · line 1268 · raw

@target:String -> Item

def group source · line 1271 · raw

@name:String -> Item

def color source · line 1274 · raw

Item

def completions source · line 1278 · raw

Item

Builtin{} marks the subcommands that only eval acts on (§6.4).

def man source · line 1281 · raw

Item

def name_start source · line 1305 · raw

@+c:Char -> Bool

def name_char source · line 1308 · raw

@+c:Char -> Bool

def finish_name source · line 1313 · raw

@rev:String -> @rest:String -> @+pos:Nat -> @+first:Bool -> @+dot_start:Nat -> NameScan

rev is the name so far, reversed.

def scan_name source · line 1319 · raw

@s:String -> @+pos:Nat -> @rev:String -> @+first:Bool -> @dot_start:Nat -> NameScan

def ph_stop source · line 1337 · raw

@at_close:Bool -> @rev:String -> @rest:String -> @+pos:Nat -> PhScan

A placeholder ends at a character no name holds: at close after a name, else with an error there.

def scan_ph source · line 1344 · raw

@s:String -> @+pos:Nat -> @rev:String -> @+close:Char -> PhScan

The placeholder name in s up to close, reversed in rev. A name holds no space, '<', '>', '[', ']' or '=', and close is one of them.

def finish_pos source · line 1355 · raw

@found:PhScan -> @kind:UsageKind -> Usage

def parse_pos source · line 1364 · raw

@s:String -> @+repeat:Bool -> Usage

def finish_required_value source · line 1375 · raw

@found:PhScan -> @id:String -> @short:String -> @long:String -> @kind:UsageKind -> Usage

def finish_optional_value source · line 1385 · raw

@found:PhScan -> @id:String -> @short:String -> @long:String -> Usage

def finish_long source · line 1395 · raw

@found:NameScan -> @short:String -> @+repeat:Bool -> @+negatable:Bool -> Usage

def parse_long_prefixed source · line 1417 · raw

@s:String -> @short:String -> @repeat:Bool -> @+start:Nat -> Usage

A long name after "--[no-]" or "--", at column start.

def parse_short_tail source · line 1430 · raw

@tail:String -> @+short:String -> @+repeat:Bool -> Usage

def parse_short source · line 1447 · raw

@s:String -> @repeat:Bool -> Usage

def parse_usage_body source · line 1456 · raw

@s:String -> @+repeat:Bool -> Usage

def ends_in_ellipsis source · line 1470 · raw

@s:String -> @run:Nat -> Bool

Whether s ends in "...": run counts the dots just before s.

def parse_usage_repeated source · line 1476 · raw

@repeated:Bool -> @+usage:String -> Usage

def parse_usage source · line 1483 · raw

@+usage:String -> Usage

def alias_valid_result source · line 1486 · raw

@parsed:Usage -> @+raw:String -> Bool

def valid_arg_alias source · line 1492 · raw

@+raw:String -> Bool

def kind_pos source · line 1495 · raw

@kind:UsageKind -> Bool

def kind_optional_pos source · line 1500 · raw

@kind:UsageKind -> Bool

def kind_variadic_pos source · line 1505 · raw

@kind:UsageKind -> Bool

def kind_required_pos source · line 1510 · raw

@kind:UsageKind -> Bool

def kind_valued source · line 1515 · raw

@kind:UsageKind -> Bool

def kind_bare source · line 1522 · raw

@kind:UsageKind -> Bool

def kind_default_allowed source · line 1527 · raw

@kind:UsageKind -> Bool

def kind_required_allowed source · line 1535 · raw

@kind:UsageKind -> Bool

def kind_delim_allowed source · line 1540 · raw

@kind:UsageKind -> Bool

def bad_attr source · line 1546 · raw

@cond:Bool -> @name:String -> Maybe<&2, String>

def misplaced_attr_name source · line 1549 · raw

@attr:Item -> @+kind:UsageKind -> Maybe<&2, String>

def maybe_misplaced source · line 1577 · raw

@found:Maybe<&2, String> -> @at:String -> List<&2, Problem>

def placement_issues source · line 1583 · raw

@attrs:List<&2, Item> -> @+kind:UsageKind -> @+at:String -> List<&2, Problem>

def value_type_names source · line 1592 · raw

@attrs:List<&2, Item> -> List<&2, String>

def extra_type_issues source · line 1598 · raw

@names:List<&2, String> -> @+at:String -> List<&2, Problem>

def duplicate_type_issues source · line 1605 · raw

@names:List<&2, String> -> @at:String -> List<&2, Problem>

def command_attr_name source · line 1611 · raw

@attr:Item -> @root:Bool -> Maybe<&2, String>

def has_rest source · line 1642 · raw

@items:List<&2, Item> -> Bool

def has_hidden source · line 1648 · raw

@items:List<&2, Item> -> Bool

def has_builtin source · line 1654 · raw

@items:List<&2, Item> -> Bool

def has_bare source · line 1660 · raw

@items:List<&2, Item> -> Bool

def has_required source · line 1666 · raw

@items:List<&2, Item> -> Bool

def duplicate_strings source · line 1672 · raw

@xs:List<&2, String> -> Bool

def bad_choices source · line 1679 · raw

@items:List<&2, Item> -> Bool

def find_default source · line 1687 · raw

@items:List<&2, Item> -> Maybe<&2, String>

def find_delim source · line 1693 · raw

@attrs:List<&2, Item> -> Maybe<&2, Char>

def split_each source · line 1699 · raw

@values:List<&2, String> -> @+sep:Char -> List<&2, String>

def apply_delim source · line 1707 · raw

@found:Maybe<&2, Char> -> @values:List<&2, String> -> List<&2, String>

def find_id source · line 1713 · raw

@items:List<&2, Item> -> Maybe<&2, String>

def find_requires source · line 1719 · raw

@items:List<&2, Item> -> List<&2, String>

def find_conflicts source · line 1725 · raw

@items:List<&2, Item> -> List<&2, String>

def find_group_attrs source · line 1731 · raw

@items:List<&2, Item> -> List<&2, String>

def find_aliases source · line 1737 · raw

@items:List<&2, Item> -> List<&2, String>

def scope_groups source · line 1743 · raw

@items:List<&2, Item> -> List<&2, String>

def scope_group_rules source · line 1750 · raw

@items:List<&2, Item> -> List<&2, String>

def lint_items source · line 1770 · raw

@items:List<&2, Item> -> List<&2, LintItem>

def has_pos_item source · line 1779 · raw

@items:List<&2, LintItem> -> Bool

def has_sub_item source · line 1786 · raw

@items:List<&2, Item> -> Bool

def has_version_item source · line 1792 · raw

@items:List<&2, Item> -> Bool

def name_scan_valid source · line 1798 · raw

@result:NameScan -> Bool

def valid_command_name source · line 1803 · raw

@s:String -> Bool

def use_id source · line 1806 · raw

@found:Maybe<&2, String> -> @derived:String -> String

def usage_id source · line 1811 · raw

@parsed:Usage -> @attrs:List<&2, Item> -> String

def scope_ids source · line 1818 · raw

@items:List<&2, LintItem> -> List<&2, String>

def same_go source · line 1838 · raw

@a:String -> @b:String -> @same:Bool -> Bool

String.eq, without rebuilding both strings to hand them back; the walk stops at the first difference.

def same_text source · line 1844 · raw

@a:String -> @b:String -> Bool

def same_nonempty source · line 1847 · raw

@+a:String -> @b:String -> Bool

def arg_collision source · line 1850 · raw

@seen:List<&2, Seen> -> @+id:String -> @+short:String -> @+long:String -> Maybe<&2, String>

def sub_collision source · line 1869 · raw

@seen:List<&2, Seen> -> @+name:String -> Bool

def arg_alias_collision source · line 1880 · raw

@seen:List<&2, Seen> -> @+name:String -> Bool

def maybe_dup source · line 1891 · raw

@found:Maybe<&2, String> -> @at:String -> List<&2, Problem>

def when_problem source · line 1896 · raw

@cond:Bool -> @problem:Problem -> List<&2, Problem>

def arg_alias_issue source · line 1899 · raw

@+name:String -> @+at:String -> @seen:List<&2, Seen> -> @version:Bool -> List<&2, Problem>

def arg_alias_issues source · line 1908 · raw

@aliases:List<&2, String> -> @+at:String -> @+seen:List<&2, Seen> -> @+version:Bool -> List<&2, Problem>

def arg_alias_entries source · line 1917 · raw

@aliases:List<&2, String> -> List<&2, Seen>

def arg_entries source · line 1923 · raw

@parsed:Usage -> @+attrs:List<&2, Item> -> List<&2, Seen>

def has_global source · line 1931 · raw

@items:List<&2, Item> -> Bool

def global_entries source · line 1937 · raw

@items:List<&2, LintItem> -> List<&2, Seen>

def sub_alias_issue source · line 1947 · raw

@+name:String -> @+at:String -> @seen:List<&2, Seen> -> List<&2, Problem>

def sub_alias_issues source · line 1955 · raw

@aliases:List<&2, String> -> @+at:String -> @+seen:List<&2, Seen> -> List<&2, Problem>

def sub_alias_entries source · line 1964 · raw

@aliases:List<&2, String> -> List<&2, Seen>

def missing_refs source · line 1970 · raw

@targets:List<&2, String> -> @+ids:List<&2, String> -> @+at:String -> List<&2, Problem>

def valid_u32 source · line 1981 · raw

@s:String -> Bool

A U32 value is what U32.read reads (P22).

def decimal_digits source · line 1985 · raw

@s:String -> Bool

Decimal digits by Nat.read's own test, which Char.is_digit agrees with.

def valid_nat source · line 1993 · raw

@+s:String -> Bool

A Nat value is what Nat.read reads (P22): digits that, less leading zeroes, fit under its cap of 2^48-1.

def valid_bool source · line 1997 · raw

@s:String -> Bool

def is_exponent source · line 2014 · raw

@+c:Char -> Bool

def is_sign source · line 2017 · raw

@+c:Char -> Bool

def decimal_step source · line 2020 · raw

@state:DecimalState -> @+c:Char -> DecimalState

def decimal_accept source · line 2051 · raw

@state:DecimalState -> Bool

def decimal_scan source · line 2059 · raw

@s:String -> @state:DecimalState -> Bool

def valid_f32 source · line 2065 · raw

@s:String -> Bool

def find_one_of source · line 2068 · raw

@items:List<&2, Item> -> Maybe<&2, List<&2, String>>

def find_as source · line 2078 · raw

@attrs:List<&2, Item> -> Maybe<&2, ValueType>

def type_reason source · line 2084 · raw

@kind:ValueType -> @value:String -> Maybe<&2, String>

def quoted_choices source · line 2101 · raw

@values:List<&2, String> -> List<&2, String>

def choices_reason source · line 2107 · raw

@values:List<&2, String> -> String

def choice_reason_if source · line 2111 · raw

@ok:Bool -> @values:List<&2, String> -> Maybe<&2, String>

def choice_reason source · line 2116 · raw

@found:Maybe<&2, List<&2, String>> -> @value:String -> Maybe<&2, String>

def reason_from_type source · line 2124 · raw

@found:Maybe<&2, ValueType> -> @value:String -> Maybe<&2, String>

def first_reason source · line 2130 · raw

@found:Maybe<&2, String> -> @other:Maybe<&2, String> -> Maybe<&2, String>

def value_reason source · line 2136 · raw

@+attrs:List<&2, Item> -> @+value:String -> Maybe<&2, String>

def bad_value source · line 2141 · raw

@reason:Maybe<&2, String> -> @value:String -> Maybe<&2, Bad>

def first_bad source · line 2147 · raw

@values:List<&2, String> -> @+attrs:List<&2, Item> -> Maybe<&2, Bad>

def split_bad source · line 2155 · raw

@found:Maybe<&2, Char> -> @attrs:List<&2, Item> -> @+value:String -> Maybe<&2, Bad>

def value_bad source · line 2162 · raw

@+attrs:List<&2, Item> -> @value:String -> Maybe<&2, Bad>

A delimited value splits first; the first element that fails (§8.2).

def value_issue source · line 2166 · raw

@kind:UsageKind -> @attrs:List<&2, Item> -> @+value:String -> Maybe<&2, Bad>

A value from env or a default converts each element on its own (§8.2).

def bad_default source · line 2174 · raw

@required:Bool -> @issue:Maybe<&2, Bad> -> @value:String -> @id:String -> @at:String -> List<&2, Problem>

def check_default source · line 2181 · raw

@found:Maybe<&2, String> -> @kind:UsageKind -> @+attrs:List<&2, Item> -> @id:String -> @at:String -> List<&2, Problem>

def choice_bad source · line 2191 · raw

@values:List<&2, String> -> @+found:Maybe<&2, ValueType> -> @bad:Maybe<&2, Bad> -> Maybe<&2, Bad>

The first choice the arg's type rejects; after a hit it only walks the rest.

def bad_choice source · line 2199 · raw

@found:Maybe<&2, Bad> -> @id:String -> @at:String -> List<&2, Problem>

def check_choices source · line 2207 · raw

@found:Maybe<&2, List<&2, String>> -> @kind:Maybe<&2, ValueType> -> @id:String -> @at:String -> List<&2, Problem>

Parse checks a value's type before its choices, so a choice the type rejects could never be given.

def positional_issue source · line 2213 · raw

@+kind:UsageKind -> @+id:String -> @attrs:List<&2, Item> -> @rest_items:List<&2, LintItem> -> @+seen_optional:Bool -> @+seen_variadic:Bool -> @+at:String -> List<&2, Problem>

def bare_issue source · line 2230 · raw

@+kind:UsageKind -> @id:String -> @short:String -> @+attrs:List<&2, Item> -> @at:String -> List<&2, Problem>

def misplaced_arg source · line 2239 · raw

@+kind:UsageKind -> @+attrs:List<&2, Item> -> @+at:String -> List<&2, Problem>

def arg_reserved_dup source · line 2244 · raw

@+at:String -> @+long:String -> @seen:List<&2, Seen> -> @id:String -> @short:String -> @version:Bool -> List<&2, Problem>

def arg_issues source · line 2251 · raw

@+kind:UsageKind -> @+id:String -> @+short:String -> @+long:String -> @usage:String -> @help:String -> @+attrs:List<&2, Item> -> @remaining:List<&2, LintItem> -> @+at:String -> @ids:List<&2, String> -> @seen:List<&2, Seen> -> @optional:Bool -> @variadic:Bool -> @version:Bool -> List<&2, Problem>

def arg_problems source · line 2270 · raw

@parsed:Usage -> @+usage:String -> @help:String -> @+attrs:List<&2, Item> -> @remaining:List<&2, LintItem> -> @+at:String -> @ids:List<&2, String> -> @+seen:List<&2, Seen> -> @optional:Bool -> @variadic:Bool -> @+version:Bool -> List<&2, Problem>

def has_external source · line 2288 · raw

@items:List<&2, Item> -> Bool

def has_sub_optional source · line 2294 · raw

@items:List<&2, Item> -> Bool

def needs_sub source · line 2301 · raw

@+items:List<&2, Item> -> Bool

A command that cannot complete without a subcommand (§8.4).

def required_misplaced source · line 2307 · raw

@attrs:List<&2, Item> -> @+at:String -> List<&2, Problem>

Each required() among attrs, as Misplaced at at.

def dead_required_option source · line 2315 · raw

@option:Bool -> @attrs:List<&2, Item> -> @+at:String -> List<&2, Problem>

def dead_required_kind source · line 2323 · raw

@parsed:Usage -> @attrs:List<&2, Item> -> @+at:String -> List<&2, Problem>

An option's required() that descent drops; a flag's or a positional's is already misplaced by its kind.

def dead_required_arg source · line 2330 · raw

@kept:Bool -> @usage:String -> @attrs:List<&2, Item> -> @+at:String -> List<&2, Problem>

def dead_required_items source · line 2336 · raw

@items:List<&2, Item> -> @+at:String -> List<&2, Problem>

def dead_required source · line 2349 · raw

@dead:Bool -> @items:List<&2, Item> -> @+at:String -> List<&2, Problem>

A command that needs a subcommand passes down only its global options' values (§8.4), so another option's required() can never be met.

def command_body_issues source · line 2356 · raw

@+at:String -> @name:String -> @about:String -> @+items:List<&2, Item> -> @has_pos:Bool -> List<&2, Problem>

has_pos: whether items has a positional.

def sub_name_issues source · line 2367 · raw

@+at:String -> @+name:String -> @seen:List<&2, Seen> -> List<&2, Problem>

def lint source · line 2375 · raw

@items:List<&2, LintItem> -> @+at:String -> @+ids:List<&2, String> -> @+seen:List<&2, Seen> -> @+inherited:List<&2, Seen> -> @+optional:Bool -> @+variadic:Bool -> @+version:Bool -> @+root:Bool -> List<&2, Problem>

def status_fits source · line 2414 · raw

@+code:U32 -> Bool

A usage_status code that is an exit status, from 1 to 255.

def status_issues source · line 2418 · raw

@items:List<&2, Item> -> @+at:String -> List<&2, Problem>

Each usage_status among a root's items whose code does not fit.

def problems source · line 2427 · raw

@c:Cmd -> List<&2, Problem>

def host source · line 2508 · raw

@width:Nat -> Host

def host_var source · line 2511 · raw

@h:Host -> @name:String -> @value:String -> Host

def var_value source · line 2516 · raw

@vars:List<&2, Var> -> @+name:String -> Maybe<&2, String>

def host_value source · line 2523 · raw

@h:Host -> @name:String -> Maybe<&2, String>

def arg_info_parsed source · line 2581 · raw

@parsed:Usage -> @usage:String -> @+attrs:List<&2, Item> -> ArgInfo

def arg_info source · line 2590 · raw

@+usage:String -> @attrs:List<&2, Item> -> ArgInfo

def arg_display source · line 2593 · raw

@info:ArgInfo -> String

def short_digit source · line 2600 · raw

@short:String -> Bool

def info_attrs source · line 2605 · raw

@info:ArgInfo -> List<&2, Item>

def info_kind source · line 2609 · raw

@info:ArgInfo -> UsageKind

def info_id source · line 2613 · raw

@info:ArgInfo -> String

def scope_path source · line 2617 · raw

@scope:Scope -> List<&2, String>

def arg_in_group source · line 2621 · raw

@attrs:List<&2, Item> -> @name:String -> Bool

def group_global source · line 2626 · raw

@items:List<&2, Item> -> @+name:String -> Bool

Whether each arg items put in group name is global().

def global_go source · line 2637 · raw

@items:List<&2, Item> -> @+all:List<&2, Item> -> List<&2, Item>

What items pass down to their subcommands, in their order: each global() arg, and each exclusive or need_one rule over a group whose args in all are each global(), so that it holds in every subcommand below.

def global_items source · line 2655 · raw

@+items:List<&2, Item> -> List<&2, Item>

def kind_negatable source · line 2658 · raw

@kind:UsageKind -> Bool

def negated_long source · line 2663 · raw

@long:String -> String

def option_matches source · line 2666 · raw

@+query:String -> @info:ArgInfo -> Maybe<&2, OptFound>

def find_option source · line 2682 · raw

@items:List<&2, Item> -> @+query:String -> Maybe<&2, OptFound>

def key_found source · line 2693 · raw

@key:OptKey -> @query:String -> Maybe<&2, OptFound>

def find_key source · line 2700 · raw

@keys:List<&2, OptKey> -> @+query:String -> @found:Maybe<&2, OptFound> -> Maybe<&2, OptFound>

The first key named query; after a hit it only walks the rest.

def head_named source · line 2709 · raw

@keys:List<&2, OptKey> -> @+query:String -> Bool

Whether keys' first key is named query. It only reads keys, so a walk that asks before it takes a key need not copy the keys it passes.

def key_rank source · line 2717 · raw

@keys:List<&2, OptKey> -> @+query:String -> @at:Nat -> @hit:Bool -> Maybe<&2, Nat>

The position of the first of keys named query, where hit says whether keys' head is and at is its position. It only reads keys: a walk that takes them, as find_key does, copies every field of each key it passes.

def key_found_at source · line 2726 · raw

@key:Maybe<&2, OptKey> -> Maybe<&2, OptFound>

def key_at source · line 2733 · raw

@rank:Maybe<&2, Nat> -> @keys:List<&2, OptKey> -> Maybe<&2, OptFound>

List.get drops each key it passes whole, where a walk over OptKey would open it.

def key_lookup source · line 2740 · raw

@+keys:List<&2, OptKey> -> @+query:String -> Maybe<&2, OptFound>

find_key(keys, query, None{}), copying only the key it finds.

def key_known source · line 2747 · raw

@+keys:List<&2, OptKey> -> @+query:String -> Bool

Whether keys hold one named query, read without copying the key.

def find_option_scope source · line 2752 · raw

@scope:Scope -> @query:String -> Maybe<&2, OptFound>

A scope's own args answer before its globals, as in find_option.

def has_alias source · line 2760 · raw

@items:List<&2, Item> -> @+query:String -> @found:Bool -> Bool

Whether items alias query; after a hit it walks no further.

def alias_hit source · line 2768 · raw

@aliased:Bool -> @name:String -> @children:List<&2, Item> -> Maybe<&2, SubFound>

def sub_hit source · line 2774 · raw

@same:Bool -> @name:String -> @+children:List<&2, Item> -> @query:String -> Maybe<&2, SubFound>

def sub_found source · line 2781 · raw

@item:Item -> @+query:String -> Maybe<&2, SubFound>

def find_sub_go source · line 2788 · raw

@items:List<&2, Item> -> @+query:String -> @found:Maybe<&2, SubFound> -> Maybe<&2, SubFound>

The first Sub named or aliased query; after a hit it walks no further.

def find_sub source · line 2795 · raw

@items:List<&2, Item> -> @+query:String -> Maybe<&2, SubFound>

def positional_items source · line 2799 · raw

@items:List<&2, Item> -> List<&2, Item>

def has_variadic_pos source · line 2809 · raw

@items:List<&2, Item> -> Bool

def positional_can_take source · line 2817 · raw

@items:List<&2, Item> -> @count:Nat -> Bool

def opt_key source · line 2824 · raw

@+name:String -> @info:ArgInfo -> OptKey

name as a key of info; only info's --no- long clears the flag, as in option_matches.

def name_keys source · line 2832 · raw

@names:List<&2, String> -> @+info:ArgInfo -> List<&2, OptKey>

def nonempty_name source · line 2838 · raw

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

def info_names source · line 2842 · raw

@info:ArgInfo -> List<&2, String>

The names option_matches accepts for info, in its order.

def spec_keys source · line 2852 · raw

@items:List<&2, SpecItem> -> List<&2, OptKey>

def spec_items source · line 2861 · raw

@items:List<&2, Item> -> List<&2, SpecItem>

items less their Subs, each Arg's usage parsed once.

def global_spec source · line 2870 · raw

@items:List<&2, SpecItem> -> @+all:List<&2, Item> -> List<&2, SpecItem>

global_go over items parsed, with all as written.

def spec_slots source · line 2889 · raw

@items:List<&2, SpecItem> -> List<&2, ArgInfo>

def slots_variadic source · line 2898 · raw

@slots:List<&2, ArgInfo> -> Bool

def info_digit_short source · line 2904 · raw

@info:ArgInfo -> Bool

def spec_digit_short source · line 2908 · raw

@items:List<&2, SpecItem> -> Bool

def raw_subs source · line 2915 · raw

@items:List<&2, Item> -> List<&2, SubKey>

def spec_node source · line 2924 · raw

@+items:List<&2, Item> -> @+globals:List<&2, SpecItem> -> Spec

items as a scope inheriting globals; its subcommands stay unparsed until the scan enters one.

def scan_start source · line 2935 · raw

@c:Cmd -> ScanState

def scan_event source · line 2941 · raw

@state:ScanState -> @event:ScanEvent -> ScanState

def first_issue source · line 2948 · raw

@issue:Maybe<&2, ScanFault> -> @fault:ScanFault -> Maybe<&2, ScanFault>

def scan_error source · line 2954 · raw

@state:ScanState -> @fault:ScanFault -> ScanState

def has_hyphen source · line 2961 · raw

@items:List<&2, Item> -> Bool

def has_as_f32 source · line 2967 · raw

@items:List<&2, Item> -> Bool

def slot_here source · line 2980 · raw

@slots:List<&2, ArgInfo> -> @count:Nat -> Bool

Whether slots' first slot takes the operand after count others: it is the count'th, or variadic.

def slot_traits_go source · line 2989 · raw

@slots:List<&2, ArgInfo> -> @count:Nat -> @here:Bool -> SlotTraits

The traits of the first of slots that takes the operand after count others, where here says whether slots' head does. It only reads slots: a walk that returned the slot would copy each of its fields.

def scope_slot_traits source · line 3000 · raw

@scope:Scope -> @+count:Nat -> SlotTraits

def traits_rest source · line 3006 · raw

@traits:SlotTraits -> Bool

def is_negative_number source · line 3010 · raw

@+s:String -> Bool

def before_equal source · line 3013 · raw

@s:String -> String

def after_equal source · line 3019 · raw

@s:String -> Maybe<&2, String>

def first_option_name source · line 3025 · raw

@+token:String -> String

def scope_option_known source · line 3029 · raw

@scope:Scope -> @token:String -> Bool

def scope_builtin_known source · line 3035 · raw

@scope:Scope -> @+token:String -> Bool

def scope_any_option_known source · line 3047 · raw

@+scope:Scope -> @+token:String -> Bool

def scan_operand_ok source · line 3051 · raw

@state:ScanState -> @token:String -> ScanState

def scan_operand_case source · line 3060 · raw

@allowed:Bool -> @state:ScanState -> @token:String -> ScanState

def slots_can_take source · line 3066 · raw

@slots:List<&2, ArgInfo> -> @count:Nat -> Bool

def scope_can_take source · line 3072 · raw

@scope:Scope -> @count:Nat -> Bool

def scan_operand source · line 3078 · raw

@state:ScanState -> @token:String -> ScanState

def spec_inherit source · line 3086 · raw

@spec:Spec -> List<&2, SpecItem>

def event_id source · line 3091 · raw

@event:ScanEvent -> Maybe<&2, String>

def spec_info_found source · line 3098 · raw

@item:SpecItem -> @id:String -> Maybe<&2, ArgInfo>

def find_spec_info source · line 3106 · raw

@items:List<&2, SpecItem> -> @+id:String -> @found:Maybe<&2, ArgInfo> -> Maybe<&2, ArgInfo>

find_arg_info over parsed items; after a hit it only walks the rest.

def event_inherited source · line 3117 · raw

@found:Maybe<&2, String> -> @+globals:List<&2, SpecItem> -> Bool

An arg's hits from before the scan enters a subcommand stay only when the scope being left passes the arg down as a global (SPEC 8.4); operands, entries, help and version stay.

def events_kept source · line 3124 · raw

@keep:Bool -> @event:ScanEvent -> @rest:List<&2, ScanEvent> -> List<&2, ScanEvent>

def events_inherited source · line 3130 · raw

@events:List<&2, ScanEvent> -> @+globals:List<&2, SpecItem> -> List<&2, ScanEvent>

def scan_descend source · line 3138 · raw

@state:ScanState -> @sub:SubKey -> ScanState

def scan_external source · line 3153 · raw

@state:ScanState -> @name:String -> @args:List<&2, String> -> ScanState

def scan_value_result source · line 3162 · raw

@found:Maybe<&2, Bad> -> @state:ScanState -> @info:ArgInfo -> @value:String -> ScanState

E04 quotes the first element that fails.

def scan_value source · line 3172 · raw

@state:ScanState -> @info:ArgInfo -> @+value:String -> ScanState

def scan_simple_hit source · line 3179 · raw

@state:ScanState -> @info:ArgInfo -> @polarity:Bool -> ScanState

def scan_settle_case source · line 3187 · raw

@resting:Bool -> @issue:Maybe<&2, ScanFault> -> @scope:Scope -> @events:List<&2, ScanEvent> -> @positional_count:Nat -> @external:Maybe<&2, ExternalArgs> -> Mode

def scan_settle source · line 3204 · raw

@state:ScanState -> Mode

def help_flag_case source · line 3211 · raw

@long:Bool -> @short:Bool -> Maybe<&2, Bool>

def help_flag source · line 3218 · raw

@+token:String -> Maybe<&2, Bool>

Which help flag a token is: Some{True{}} for --help, Some{False{}} for -h.

def scan_faulted_case source · line 3221 · raw

@help:Maybe<&2, Bool> -> @state:ScanState -> Tail

def scan_faulted source · line 3226 · raw

@state:ScanState -> @token:String -> Tail

def scope_digit_short source · line 3229 · raw

@scope:Scope -> Bool

def arg_has_hyphen source · line 3234 · raw

@info:ArgInfo -> Bool

def arg_is_f32 source · line 3239 · raw

@info:ArgInfo -> Bool

def fetch_dash_allowed source · line 3245 · raw

@scope:Scope -> @+info:ArgInfo -> @+token:String -> Bool

Whether info's value may be token, which starts with "-".

def fetch_allowed_case source · line 3254 · raw

@dash:Bool -> @scope:Scope -> @info:ArgInfo -> @token:String -> Bool

def fetch_allowed source · line 3260 · raw

@scope:Scope -> @info:ArgInfo -> @+token:String -> Bool

def scan_fetch_result source · line 3263 · raw

@allowed:Bool -> @state:ScanState -> @info:ArgInfo -> @token:String -> Mode

def scan_state_scope source · line 3270 · raw

@state:ScanState -> Scope

def starts_with_dash source · line 3275 · raw

@s:String -> Bool

def scan_fetch_case source · line 3280 · raw

@dash:Bool -> @+state:ScanState -> @+info:ArgInfo -> @+token:String -> Mode

def scan_fetch source · line 3289 · raw

@state:ScanState -> @info:ArgInfo -> @+token:String -> Mode

def bare_value source · line 3293 · raw

@attrs:List<&2, Item> -> String

def scan_option source · line 3299 · raw

@attached:Maybe<&2, String> -> @state:ScanState -> @info:ArgInfo -> Mode

def info_bare_value source · line 3305 · raw

@info:ArgInfo -> String

def scan_bare_option source · line 3310 · raw

@attached:Maybe<&2, String> -> @state:ScanState -> @+info:ArgInfo -> Mode

def scan_simple_option source · line 3317 · raw

@attached:Maybe<&2, String> -> @state:ScanState -> @info:ArgInfo -> @polarity:Bool -> Mode

def scan_found_kind source · line 3324 · raw

@kind:UsageKind -> @attached:Maybe<&2, String> -> @state:ScanState -> @info:ArgInfo -> @polarity:Bool -> Mode

def scan_found source · line 3340 · raw

@found:OptFound -> @attached:Maybe<&2, String> -> @state:ScanState -> Mode

def scope_version source · line 3346 · raw

@scope:Scope -> Bool

def scan_builtin_hit source · line 3352 · raw

@attached:Maybe<&2, String> -> @state:ScanState -> @event:ScanEvent -> @name:String -> Mode

def traits_hyphen source · line 3358 · raw

@traits:SlotTraits -> Bool

def scan_state_hyphen source · line 3364 · raw

@state:ScanState -> Bool

Whether the slot after state's operands takes hyphen values, as a rest() slot does until it has its first value.

def long_token source · line 3372 · raw

@attached:Maybe<&2, String> -> @name:String -> String

The long token that before_equal and after_equal split into name and attached.

def scan_unknown_long_case source · line 3377 · raw

@hyphen:Bool -> @name:String -> @attached:Maybe<&2, String> -> @state:ScanState -> Mode

def scan_unknown_long source · line 3387 · raw

@name:String -> @attached:Maybe<&2, String> -> @+state:ScanState -> Mode

A long token that names no option, declared or built-in: a value of the next slot if that slot takes hyphen values, else unknown. Only here is the token rebuilt from its name and attached value, so a token that names an option is split once and not kept.

def scan_builtin_other source · line 3391 · raw

@version:Bool -> @name:String -> @attached:Maybe<&2, String> -> @state:ScanState -> Mode

def scan_builtin_long_case source · line 3398 · raw

@help:Bool -> @+name:String -> @attached:Maybe<&2, String> -> @+state:ScanState -> Mode

def scan_builtin_long source · line 3407 · raw

@+name:String -> @attached:Maybe<&2, String> -> @state:ScanState -> Mode

def scan_long_found source · line 3411 · raw

@found:Maybe<&2, OptFound> -> @name:String -> @attached:Maybe<&2, String> -> @state:ScanState -> Mode

def scan_long source · line 3417 · raw

@+token:String -> @+state:ScanState -> Mode

def scan_state_keys source · line 3423 · raw

@state:ScanState -> List<&2, OptKey>

The keys of state's scope.

def find_short_for_head source · line 3429 · raw

@chars:String -> @keys:List<&2, OptKey> -> Maybe<&2, OptFound>

def short_attached source · line 3436 · raw

@chars:String -> String

def scan_short_value_attached source · line 3441 · raw

@value:String -> @state:ScanState -> @info:ArgInfo -> Mode

def scan_short_value source · line 3447 · raw

@chars:String -> @state:ScanState -> @info:ArgInfo -> Mode

def scan_short_bare_value source · line 3451 · raw

@chars:String -> @state:ScanState -> @+info:ArgInfo -> Mode

def scan_short_version source · line 3459 · raw

@enabled:Bool -> @state:ScanState -> Mode

def scan_short_go source · line 3464 · raw

@chars:String -> @+state:ScanState -> @found:Maybe<&2, OptFound> -> Mode

def scan_short source · line 3503 · raw

@+state:ScanState -> @token:String -> Mode

The lookup takes only the scope's keys: an accessor for them would take the state and copy each of its fields.

def scope_external source · line 3512 · raw

@scope:Scope -> Bool

def scope_has_sub source · line 3517 · raw

@scope:Scope -> Bool

def sub_key_aliased source · line 3522 · raw

@aliased:Bool -> @name:String -> @aliases:List<&2, String> -> @children:List<&2, Item> -> Maybe<&2, SubKey>

def sub_key_hit source · line 3528 · raw

@same:Bool -> @name:String -> @+aliases:List<&2, String> -> @children:List<&2, Item> -> @query:String -> Maybe<&2, SubKey>

def sub_key_found source · line 3536 · raw

@key:SubKey -> @+query:String -> Maybe<&2, SubKey>

def find_sub_key source · line 3542 · raw

@subs:List<&2, SubKey> -> @+query:String -> @found:Maybe<&2, SubKey> -> Maybe<&2, SubKey>

find_sub over a scope's subcommands; after a hit it only walks the rest.

def scope_find_sub source · line 3550 · raw

@scope:Scope -> @query:String -> Maybe<&2, SubKey>

def scan_sub_unknown source · line 3556 · raw

@allow_external:Bool -> @state:ScanState -> @token:String -> Mode

def scan_sub_found source · line 3562 · raw

@found:Maybe<&2, SubKey> -> @+state:ScanState -> @token:String -> Mode

def unknown_fault source · line 3570 · raw

@dash:Bool -> @token:String -> ScanFault

def help_missing_case source · line 3575 · raw

@help:Maybe<&2, Bool> -> @+token:String -> @state:ScanState -> Tail

def help_missing source · line 3583 · raw

@+token:String -> @state:ScanState -> Tail

def help_walk source · line 3586 · raw

@found:Maybe<&2, SubKey> -> @state:ScanState -> @token:String -> Tail

def scan_non_option_sub_case source · line 3592 · raw

@help:Bool -> @+token:String -> @+state:ScanState -> Mode

def scan_non_option_sub source · line 3600 · raw

@+token:String -> @state:ScanState -> Mode

def scan_non_option_case source · line 3603 · raw

@has_sub:Bool -> @token:String -> @state:ScanState -> Mode

def scan_state_has_sub source · line 3609 · raw

@state:ScanState -> Bool

def scan_non_option source · line 3615 · raw

@token:String -> @+state:ScanState -> Mode

def hyphen_operand source · line 3621 · raw

@hyphen:Bool -> @scope:Scope -> @token:String -> Bool

Whether a slot that takes hyphen values takes a dash token: no option in scope is named by it. The lookup runs only for such a slot, which a rest() slot is until it has its first value.

def f32_operand source · line 3627 · raw

@f32:Bool -> @scope:Scope -> @token:String -> Bool

Whether an f32 slot takes token as a negative number.

def slot_candidate source · line 3633 · raw

@traits:SlotTraits -> @+scope:Scope -> @+token:String -> Bool

def scan_hyphen_candidate source · line 3640 · raw

@state:ScanState -> @+token:String -> Bool

def scan_dash_case source · line 3646 · raw

@operand:Bool -> @token:String -> @state:ScanState -> Mode

def scan_dash_token source · line 3651 · raw

@+token:String -> @+state:ScanState -> Mode

def token_class source · line 3662 · raw

@token:String -> TokenClass

def scan_token_case source · line 3669 · raw

@kind:TokenClass -> @token:String -> @state:ScanState -> Mode

def scan_token source · line 3676 · raw

@+token:String -> @state:ScanState -> Mode

def scan_tail source · line 3679 · raw

@tail:Tail -> @+token:String -> Tail

def scan_open source · line 3688 · raw

@dash:Bool -> @state:ScanState -> @token:String -> Mode

-- ends options only here, while the scan is open (R1).

def scan_go source · line 3694 · raw

@tokens:List<&2, String> -> @mode:Mode -> Mode

An external subcommand takes the rest of argv verbatim.

def scan_tail_close source · line 3708 · raw

@tail:Tail -> ScanState

def scan_close source · line 3714 · raw

@mode:Mode -> ScanState

def scan_trace_of source · line 3722 · raw

@state:ScanState -> @ended:Bool -> ScanTrace

def scan_trace source · line 3731 · raw

@mode:Mode -> ScanTrace

def scan source · line 3736 · raw

@c:Cmd -> @argv:List<&2, String> -> ScanTrace

def find_early source · line 3739 · raw

@events:List<&2, ScanEvent> -> Maybe<&2, Early>

def scope_needs_sub source · line 3746 · raw

@scope:Scope -> Bool

def bool_text source · line 3751 · raw

@value:Bool -> String

def gather_value source · line 3754 · raw

@gather:Gather -> @value:String -> @many:Bool -> Gather

def gather_flag source · line 3762 · raw

@gather:Gather -> @value:Bool -> Gather

def gather_count source · line 3767 · raw

@gather:Gather -> Gather

def kind_many source · line 3772 · raw

@kind:UsageKind -> Bool

def gather_value_if source · line 3780 · raw

@hit:Bool -> @gather:Gather -> @value:String -> @kind:UsageKind -> Gather

gather with a hit's value, or as it was on a miss: a match, not Bool.pick, so a miss builds nothing.

def gather_flag_if source · line 3786 · raw

@hit:Bool -> @gather:Gather -> @value:Bool -> Gather

def gather_count_if source · line 3791 · raw

@hit:Bool -> @gather:Gather -> Gather

def gather_event source · line 3796 · raw

@event:ScanEvent -> @id:String -> @kind:UsageKind -> @gather:Gather -> Gather

def gather_events source · line 3806 · raw

@events:List<&2, ScanEvent> -> @+id:String -> @+kind:UsageKind -> @gather:Gather -> Gather

def find_envs source · line 3815 · raw

@attrs:List<&2, Item> -> List<&2, String>

Each env() name, in order.

def env_present source · line 3821 · raw

@name:String -> @found:Maybe<&2, String> -> Maybe<&2, EnvValue>

def env_next source · line 3830 · raw

@found:Maybe<&2, EnvValue> -> @+name:String -> @vars:List<&2, Var> -> Maybe<&2, EnvValue>

found, or else name's value in vars if it is set and not empty.

def env_first source · line 3837 · raw

@names:List<&2, String> -> @found:Maybe<&2, EnvValue> -> @+vars:List<&2, Var> -> Maybe<&2, EnvValue>

found, or else the first of names that is set and not empty in vars.

def host_env source · line 3843 · raw

@h:Host -> @names:List<&2, String> -> Maybe<&2, EnvValue>

def env_bool_true source · line 3848 · raw

@value:String -> Bool

def env_values source · line 3852 · raw

@kind:UsageKind -> @attrs:List<&2, Item> -> @value:String -> List<&2, String>

def resolve_env_valid source · line 3860 · raw

@found:Maybe<&2, Bad> -> @info:ArgInfo -> @name:String -> @value:String -> FieldBuild

def resolve_env source · line 3870 · raw

@+info:ArgInfo -> @env:EnvValue -> FieldBuild

def resolve_default source · line 3876 · raw

@found:Maybe<&2, String> -> @info:ArgInfo -> FieldBuild

def info_default source · line 3885 · raw

@info:ArgInfo -> Maybe<&2, String>

def resolve_env_default source · line 3890 · raw

@found:Maybe<&2, EnvValue> -> @+info:ArgInfo -> FieldBuild

def gather_values source · line 3896 · raw

@kind:UsageKind -> @values:List<&2, String> -> @count:Nat -> List<&2, String>

def resolve_argv_gather source · line 3902 · raw

@gather:Gather -> @info:ArgInfo -> @h:Host -> FieldBuild

def event_for source · line 3916 · raw

@event:ScanEvent -> @id:String -> Bool

def has_event source · line 3923 · raw

@events:List<&2, ScanEvent> -> @+id:String -> @found:Bool -> Bool

def gather_hit source · line 3931 · raw

@hit:Bool -> @events:List<&2, ScanEvent> -> @id:String -> @kind:UsageKind -> Gather

def resolve_option source · line 3937 · raw

@info:ArgInfo -> @+events:List<&2, ScanEvent> -> @h:Host -> FieldBuild

def scope_arg_items source · line 3945 · raw

@scope:Scope -> List<&2, SpecItem>

def combine_built source · line 3950 · raw

@fields:List<&2, Field> -> @next:FieldBuild -> FieldBuild

def combine_build source · line 3957 · raw

@first:FieldBuild -> @second:FieldBuild -> FieldBuild

def resolve_arg source · line 3963 · raw

@pos:Bool -> @+info:ArgInfo -> @events:List<&2, ScanEvent> -> @h:Host -> @later:FieldBuild -> FieldBuild

def resolve_options source · line 3969 · raw

@items:List<&2, SpecItem> -> @+events:List<&2, ScanEvent> -> @+h:Host -> FieldBuild

def scan_operands source · line 3978 · raw

@events:List<&2, ScanEvent> -> List<&2, String>

def position_take_count source · line 3986 · raw

@kind:UsageKind -> @after:List<&2, ArgInfo> -> @+tokens:List<&2, String> -> Nat

def pos_valid_result source · line 3995 · raw

@found:Maybe<&2, Bad> -> @info:ArgInfo -> @values:List<&2, String> -> FieldBuild

def resolve_pos source · line 4005 · raw

@info:ArgInfo -> @values:List<&2, String> -> @h:Host -> FieldBuild

def resolve_positions source · line 4016 · raw

@slots:List<&2, ArgInfo> -> @+tokens:List<&2, String> -> @+h:Host -> FieldBuild

def scope_positions source · line 4026 · raw

@scope:Scope -> List<&2, ArgInfo>

def resolve_scope source · line 4031 · raw

@+scope:Scope -> @+events:List<&2, ScanEvent> -> @+h:Host -> FieldBuild

def source_given source · line 4038 · raw

@source:Src -> Bool

def field_source source · line 4045 · raw

@fields:List<&2, Field> -> @+id:String -> Src

def field_given source · line 4052 · raw

@fields:List<&2, Field> -> @id:String -> Bool

def source_present source · line 4055 · raw

@source:Src -> Bool

def field_present source · line 4060 · raw

@fields:List<&2, Field> -> @id:String -> Bool

def group_usages source · line 4063 · raw

@items:List<&2, Item> -> @+name:String -> List<&2, String>

def spec_group_usages source · line 4073 · raw

@items:List<&2, SpecItem> -> @+name:String -> List<&2, String>

def spec_group_display source · line 4084 · raw

@items:List<&2, SpecItem> -> @name:String -> String

def group_given source · line 4087 · raw

@items:List<&2, SpecItem> -> @+fields:List<&2, Field> -> @+name:String -> Bool

def arg_required_missing source · line 4096 · raw

@info:ArgInfo -> @+fields:List<&2, Field> -> Bool

def group_display source · line 4105 · raw

@items:List<&2, Item> -> @name:String -> String

def missing_arg_if source · line 4108 · raw

@missing:Bool -> @info:ArgInfo -> List<&2, String>

def missing_arg source · line 4113 · raw

@+info:ArgInfo -> @fields:List<&2, Field> -> List<&2, String>

def missing_group_if source · line 4117 · raw

@given:Bool -> @items:List<&2, SpecItem> -> @name:String -> List<&2, String>

def missing_group source · line 4123 · raw

@+items:List<&2, SpecItem> -> @fields:List<&2, Field> -> @+name:String -> List<&2, String>

def missing_once source · line 4128 · raw

@listed:Bool -> @items:List<&2, SpecItem> -> @fields:List<&2, Field> -> @name:String -> List<&2, String>

A group's display the first time a need_one rule names it.

def missing_items source · line 4136 · raw

@items:List<&2, SpecItem> -> @+all_items:List<&2, SpecItem> -> @+fields:List<&2, Field> -> @+done:List<&2, String> -> List<&2, String>

What E06 lists, in items' order: each required arg not given, and each need_one group with no arg given that done does not name yet.

def scope_missing source · line 4154 · raw

@scope:Scope -> @fields:List<&2, Field> -> List<&2, String>

def append_new source · line 4159 · raw

@seen:Bool -> @ids:List<&2, String> -> @id:String -> List<&2, String>

def has_text source · line 4167 · raw

@names:List<&2, String> -> @+query:String -> @found:Bool -> Bool

Whether names holds query: List.contains with String.eq would copy each name it compares.

def append_unique source · line 4173 · raw

@+ids:List<&2, String> -> @+id:String -> List<&2, String>

def append_event_id source · line 4177 · raw

@found:Maybe<&2, String> -> @ids:List<&2, String> -> List<&2, String>

def argv_order source · line 4183 · raw

@events:List<&2, ScanEvent> -> @ids:List<&2, String> -> List<&2, String>

def source_env source · line 4190 · raw

@source:Src -> Bool

def env_order source · line 4195 · raw

@fields:List<&2, Field> -> @+ids:List<&2, String> -> List<&2, String>

def present_order source · line 4203 · raw

@events:List<&2, ScanEvent> -> @fields:List<&2, Field> -> List<&2, String>

def arg_info_found source · line 4207 · raw

@item:Item -> @id:String -> Maybe<&2, ArgInfo>

def find_arg_go source · line 4216 · raw

@items:List<&2, Item> -> @+id:String -> @found:Maybe<&2, ArgInfo> -> Maybe<&2, ArgInfo>

The first Arg whose id is id; after a hit it walks no further.

def find_arg_info source · line 4223 · raw

@items:List<&2, Item> -> @+id:String -> Maybe<&2, ArgInfo>

def exclusive_groups source · line 4227 · raw

@items:List<&2, SpecItem> -> List<&2, String>

def common_exclusive source · line 4234 · raw

@groups:List<&2, String> -> @+left:List<&2, String> -> @+right:List<&2, String> -> Bool

def pair_conflicts source · line 4244 · raw

@+later:ArgInfo -> @+earlier:ArgInfo -> @groups:List<&2, String> -> Bool

def pair_fault source · line 4256 · raw

@+later:ArgInfo -> @earlier:Maybe<&2, ArgInfo> -> @groups:List<&2, String> -> Maybe<&2, ScanFault>

def earlier_conflict source · line 4265 · raw

@earlier_ids:List<&2, String> -> @+later:ArgInfo -> @+items:List<&2, SpecItem> -> @+groups:List<&2, String> -> @found:Maybe<&2, ScanFault> -> Maybe<&2, ScanFault>

def conflict_for_id source · line 4277 · raw

@info:Maybe<&2, ArgInfo> -> @seen:List<&2, String> -> @items:List<&2, SpecItem> -> @groups:List<&2, String> -> Maybe<&2, ScanFault>

def conflict_go source · line 4285 · raw

@ids:List<&2, String> -> @+seen:List<&2, String> -> @+items:List<&2, SpecItem> -> @+groups:List<&2, String> -> @found:Maybe<&2, ScanFault> -> Maybe<&2, ScanFault>

def require_target_fault source · line 4299 · raw

@target:Maybe<&2, ArgInfo> -> @+requester:ArgInfo -> @fields:List<&2, Field> -> Maybe<&2, ScanFault>

def require_targets source · line 4310 · raw

@targets:List<&2, String> -> @+requester:ArgInfo -> @+items:List<&2, SpecItem> -> @+fields:List<&2, Field> -> @found:Maybe<&2, ScanFault> -> Maybe<&2, ScanFault>

def require_for_id source · line 4323 · raw

@info:Maybe<&2, ArgInfo> -> @items:List<&2, SpecItem> -> @fields:List<&2, Field> -> Maybe<&2, ScanFault>

def require_go source · line 4332 · raw

@ids:List<&2, String> -> @+items:List<&2, SpecItem> -> @+fields:List<&2, Field> -> @found:Maybe<&2, ScanFault> -> Maybe<&2, ScanFault>

def parse_requires source · line 4343 · raw

@fault:Maybe<&2, ScanFault> -> @path:List<&2, String> -> @fields:List<&2, Field> -> @external:Maybe<&2, ExternalArgs> -> ParseResult

def attr_has_relation source · line 4350 · raw

@attrs:List<&2, Item> -> Bool

def has_relations source · line 4357 · raw

@items:List<&2, SpecItem> -> @found:Bool -> Bool

def parse_conflicts source · line 4366 · raw

@fault:Maybe<&2, ScanFault> -> @+scope:Scope -> @+fields:List<&2, Field> -> @order:List<&2, String> -> @external:Maybe<&2, ExternalArgs> -> ParseResult

def parse_relations source · line 4377 · raw

@related:Bool -> @+items:List<&2, SpecItem> -> @scope:Scope -> @+fields:List<&2, Field> -> @events:List<&2, ScanEvent> -> @external:Maybe<&2, ExternalArgs> -> ParseResult

def parse_missing source · line 4389 · raw

@missing:List<&2, String> -> @+scope:Scope -> @fields:List<&2, Field> -> @events:List<&2, ScanEvent> -> @empty:Bool -> @external:Maybe<&2, ExternalArgs> -> ParseResult

def parse_built source · line 4402 · raw

@build:FieldBuild -> @+scope:Scope -> @events:List<&2, ScanEvent> -> @empty:Bool -> @external:Maybe<&2, ExternalArgs> -> ParseResult

def parse_no_issue source · line 4411 · raw

@needs_sub:Bool -> @+scope:Scope -> @+events:List<&2, ScanEvent> -> @h:Host -> @empty:Bool -> @external:Maybe<&2, ExternalArgs> -> ParseResult

def parse_issue source · line 4422 · raw

@issue:Maybe<&2, ScanFault> -> @+scope:Scope -> @events:List<&2, ScanEvent> -> @h:Host -> @empty:Bool -> @external:Maybe<&2, ExternalArgs> -> ParseResult

def parse_early source · line 4432 · raw

@found:Maybe<&2, Early> -> @+scope:Scope -> @events:List<&2, ScanEvent> -> @h:Host -> @empty:Bool -> @issue:Maybe<&2, ScanFault> -> @external:Maybe<&2, ExternalArgs> -> ParseResult

def parse_from_state source · line 4444 · raw

@state:ScanState -> @h:Host -> @empty:Bool -> ParseResult

def parse source · line 4454 · raw

@c:Cmd -> @h:Host -> @+argv:List<&2, String> -> ParseResult

def Dec source · line 4464 · raw

@-A:Type -> Type

def Dec.pure source · line 4467 · raw

@-A:Type -> @x:A -> Dec(A)

def Dec.bind source · line 4470 · raw

@-A:Type -> @-B:Type -> @r:Dec(A) -> @f:(@_:A -> Dec(B)) -> Dec(B)

def matches source · line 4479 · raw

@c:Cmd -> @r:ParseResult -> Maybe<&2, Matches>

def path source · line 4485 · raw

@m:Matches -> List<&2, String>

def external_args source · line 4489 · raw

@m:Matches -> Maybe<&1, Pair(String, List<&2, String>)>

def fail source · line 4495 · raw

@-A:Type -> @msg:String -> Dec(A)

def bug source · line 4498 · raw

@-A:Type -> @msg:String -> Dec(A)

def keep source · line 4501 · raw

@+m:Matches -> Dec(Matches)

def path_text source · line 4505 · raw

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

A command path as lint writes it: the root name, then each subcommand.

def sub_items source · line 4508 · raw

@found:Maybe<&2, SubFound> -> List<&2, Item>

def scope_args source · line 4514 · raw

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

The args in scope at path (§8.1), as parse orders them: globals first.

def kind_flag source · line 4536 · raw

@kind:UsageKind -> Bool

def kind_count source · line 4542 · raw

@kind:UsageKind -> Bool

def type_stem source · line 4548 · raw

@found:Maybe<&2, ValueType> -> String

The reader name a value type reads with: str, nat, u32, f32 or bool.

def stem_noun source · line 4556 · raw

@+stem:String -> String

def stem_article source · line 4559 · raw

@+stem:String -> String

def always_present source · line 4562 · raw

@kind:UsageKind -> @+attrs:List<&2, Item> -> Bool

def may_absent source · line 4566 · raw

@+kind:UsageKind -> @attrs:List<&2, Item> -> Bool

def kind_text source · line 4570 · raw

@kind:UsageKind -> @+stem:String -> String

def fit_name source · line 4580 · raw

@+kind:UsageKind -> @attrs:List<&2, Item> -> @+stem:String -> String

def kind_verdict source · line 4591 · raw

@fits:Bool -> @id:String -> @+kind:UsageKind -> @+attrs:List<&2, Item> -> Maybe<&2, String>

def absent_verdict source · line 4600 · raw

@absent:Bool -> @id:String -> @reader:String -> Maybe<&2, String>

def all_in source · line 4608 · raw

@xs:List<&2, String> -> @+ys:List<&2, String> -> Bool

def keys_issue source · line 4615 · raw

@same:Bool -> @id:String -> Maybe<&2, String>

def keys_verdict source · line 4622 · raw

@found:Maybe<&2, List<&2, String>> -> @+keys:List<&2, String> -> @id:String -> Maybe<&2, String>

def form_fits source · line 4630 · raw

@form:Form -> @many:Bool -> Bool

def form_one source · line 4635 · raw

@form:Form -> Bool

def value_fits source · line 4640 · raw

@stem:String -> @form:Form -> @+kind:UsageKind -> @attrs:List<&2, Item> -> Bool

def choose_fits source · line 4646 · raw

@+kind:UsageKind -> @attrs:List<&2, Item> -> Bool

def program_fits source · line 4651 · raw

@+kind:UsageKind -> @attrs:List<&2, Item> -> Bool

A program and its arguments come from one variadic string positional.

def rest_verdict source · line 4654 · raw

@rest:Bool -> @id:String -> Maybe<&2, String>

def want_verdict source · line 4663 · raw

@want:Want -> @+id:String -> @+kind:UsageKind -> @+attrs:List<&2, Item> -> Maybe<&2, String>

The first Q-static message for an arg in scope: kind, absence, then keys, or for a program, then rest().

def arg_verdict source · line 4692 · raw

@found:Maybe<&2, ArgInfo> -> @id:String -> @name:String -> @path:List<&2, String> -> @want:Want -> Maybe<&2, String>

def verdict source · line 4702 · raw

@cmd:Cmd -> @+path:List<&2, String> -> @+id:String -> @want:Want -> Maybe<&2, String>

Q-static: depends only on the spec, the path, the id and the want.

def field_found source · line 4709 · raw

@f:Field -> @id:String -> Maybe<&2, Field>

def field_seek source · line 4716 · raw

@fields:List<&2, Field> -> @+id:String -> @found:Maybe<&2, Field> -> Field

The field for id, or an absent one; after a hit it walks no further.

def field_find source · line 4723 · raw

@fields:List<&2, Field> -> @+id:String -> Field

def true_of source · line 4759 · raw

@s:String -> Bool

def nat_of source · line 4762 · raw

@s:String -> Nat

def u32_of source · line 4765 · raw

@s:String -> U32

def f32_of source · line 4768 · raw

@s:String -> F32

def flag source · line 4771 · raw

@m:Matches -> @id:String -> Dec(Bool)

def count source · line 4774 · raw

@m:Matches -> @id:String -> Dec(Nat)

def str source · line 4778 · raw

@m:Matches -> @id:String -> Dec(String)

def str_opt source · line 4782 · raw

@m:Matches -> @id:String -> Dec(Maybe<&2, String>)

def strs source · line 4786 · raw

@m:Matches -> @id:String -> Dec(List<&2, String>)

def nat source · line 4790 · raw

@m:Matches -> @id:String -> Dec(Nat)

def nat_opt source · line 4794 · raw

@m:Matches -> @id:String -> Dec(Maybe<&2, Nat>)

def nats source · line 4798 · raw

@m:Matches -> @id:String -> Dec(List<&2, Nat>)

def u32 source · line 4802 · raw

@m:Matches -> @id:String -> Dec(U32)

def u32_opt source · line 4806 · raw

@m:Matches -> @id:String -> Dec(Maybe<&2, U32>)

def u32s source · line 4810 · raw

@m:Matches -> @id:String -> Dec(List<&2, U32>)

def f32 source · line 4814 · raw

@m:Matches -> @id:String -> Dec(F32)

def f32_opt source · line 4818 · raw

@m:Matches -> @id:String -> Dec(Maybe<&2, F32>)

def f32s source · line 4822 · raw

@m:Matches -> @id:String -> Dec(List<&2, F32>)

def bool source · line 4826 · raw

@m:Matches -> @id:String -> Dec(Bool)

def bool_opt source · line 4830 · raw

@m:Matches -> @id:String -> Dec(Maybe<&2, Bool>)

def bools source · line 4834 · raw

@m:Matches -> @id:String -> Dec(List<&2, Bool>)

def program_of source · line 4842 · raw

@values:List<&2, String> -> Program

def program_maybe source · line 4847 · raw

@values:List<&2, String> -> Maybe<&2, Program>

def get_program source · line 4852 · raw

@f:Field -> Program

def get_program_opt source · line 4856 · raw

@f:Field -> Maybe<&2, Program>

def program source · line 4863 · raw

@m:Matches -> @id:String -> Dec(Program)

§6.5: a <COMMAND>... positional with Cli.rest() as a program and its arguments, the first value and the rest, as timeout, nice and env take them: every token after the program is one of its arguments.

def program_opt source · line 4866 · raw

@m:Matches -> @id:String -> Dec(Maybe<&2, Program>)

def field_src source · line 4869 · raw

@f:Field -> Src

def given source · line 4873 · raw

@m:Matches -> @id:String -> Dec(Bool)

def source source · line 4876 · raw

@m:Matches -> @id:String -> Dec(Src)

def by_key_hit source · line 4879 · raw

@-a:Quant -> @-A:Kind(a) -> @same:Bool -> @value:A -> Maybe<a, A>

def find_by_key_go source · line 4885 · raw

@-a:Quant -> @-A:Kind(a) -> @keys:List<&2, String> -> @values:List<a, A> -> @+key:String -> @found:Maybe<a, A> -> Maybe<a, A>

The value under the first key equal to key; after a hit it walks no further.

def find_by_key source · line 4894 · raw

@-a:Quant -> @-A:Kind(a) -> @keys:List<&2, String> -> @values:List<a, A> -> @+key:String -> Maybe<a, A>

def keyed_cons source · line 4898 · raw

@-a:Quant -> @-A:Kind(a) -> @key:String -> @value:A -> @rest:Pair(List<&2, String>, List<a, A>) -> Pair(List<&2, String>, List<a, A>)

def unzip_keyed source · line 4904 · raw

@-a:Quant -> @-A:Kind(a) -> @table:List<&1, Pair(String, A)> -> Pair(List<&2, String>, List<a, A>)

A choose or route table as its keys and its values.

def choice_dec source · line 4913 · raw

@-A:Data -> @found:Maybe<&2, A> -> Dec(Maybe<&2, A>)

After validation the key exists: parse and samples keep one_of values.

def choose_read source · line 4918 · raw

@-A:Data -> @keys:List<&2, String> -> @values:List<&2, A> -> @f:Field -> Dec(Maybe<&2, A>)

def choose_check source · line 4925 · raw

@-A:Data -> @verdict:Maybe<&2, String> -> @keys:List<&2, String> -> @values:List<&2, A> -> @fields:List<&2, Field> -> @id:String -> Dec(Maybe<&2, A>)

def choose_pick source · line 4932 · raw

@-A:Data -> @opt:Bool -> @choices:Pair(List<&2, String>, List<&2, A>) -> @m:Matches -> @+id:String -> Dec(Maybe<&2, A>)

def choose_opt source · line 4941 · raw

@-A:Data -> @m:Matches -> @id:String -> @table:List<&1, Pair(String, A)> -> Dec(Maybe<&2, A>)

def choice_must source · line 4946 · raw

@-A:Data -> @d:Dec(Maybe<&2, A>) -> Dec(A)

After validation a bare choose always has a value.

def choose source · line 4952 · raw

@-A:Data -> @m:Matches -> @id:String -> @table:List<&1, Pair(String, A)> -> Dec(A)

def Call source · line 4956 · raw

@-A:Type -> Type

def word_rest source · line 4962 · raw

@name:String -> @text:String -> @same:Bool -> Maybe<&2, Maybe<&2, String>>

Some{None{}} when text is the word name, Some{Some{rest}} when it is name, a space and rest, None{} otherwise. Words are cut at spaces, so a name with a space (Chr{32}) is no word.

def key_user source · line 4981 · raw

@builtin:Bool -> @rest:Maybe<&2, String> -> KeyStep

def key_word source · line 4987 · raw

@found:Maybe<&2, Maybe<&2, String>> -> @children:List<&2, Item> -> KeyStep

def key_step source · line 4993 · raw

@items:List<&2, Item> -> @text:String -> KeyStep

def key_go source · line 5001 · raw

@items:List<&2, Item> -> @+text:String -> @step:KeyStep -> Bool

The first subcommand named by each word of text, from items down, is a command.

def route_text source · line 5011 · raw

@empty:Bool -> @+key:String -> @+items:List<&2, Item> -> Bool

def route_key source · line 5017 · raw

@+key:String -> @items:List<&2, Item> -> Bool

A route key's words name a command; "" is the root.

def non_command source · line 5020 · raw

@keys:List<&2, String> -> @+items:List<&2, Item> -> Maybe<&2, String>

def route_call source · line 5028 · raw

@-A:Type -> @bad:Maybe<&2, String> -> @call:Call(A) -> @m:Matches -> Dec(A)

def route_found source · line 5036 · raw

@-A:Type -> @found:Maybe<&1, Call(A)> -> @keys:List<&2, String> -> @cmd:Cmd -> @path:List<&2, String> -> @m:Matches -> Dec(A)

No route for the path is checked first, then every key names a command.

def route_pick source · line 5044 · raw

@-A:Type -> @routes:Pair(List<&2, String>, List<&1, Call(A)>) -> @m:Matches -> Dec(A)

def route source · line 5053 · raw

@-A:Type -> @m:Matches -> @table:List<&1, Pair(String, Call(A))> -> Dec(A)

def sample_typed source · line 5058 · raw

@found:Maybe<&2, ValueType> -> String

def sample_choice source · line 5066 · raw

@found:Maybe<&2, List<&2, String>> -> @attrs:List<&2, Item> -> String

def sample_value source · line 5072 · raw

@kind:UsageKind -> @+attrs:List<&2, Item> -> String

def sample_field source · line 5079 · raw

@build:FieldBuild -> @info:ArgInfo -> List<&2, Field>

def sample_args source · line 5089 · raw

@items:List<&2, Item> -> List<&2, Field>

Each arg in scope: its default as parse resolves it, else a sample value.

def sample_fields source · line 5099 · raw

@c:Cmd -> @path:List<&2, String> -> List<&2, Field>

def sample source · line 5103 · raw

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

def more_typed source · line 5106 · raw

@found:Maybe<&2, ValueType> -> List<&2, String>

def more_choice source · line 5111 · raw

@found:Maybe<&2, List<&2, String>> -> @attrs:List<&2, Item> -> List<&2, String>

def more_values source · line 5120 · raw

@kind:UsageKind -> @+attrs:List<&2, Item> -> List<&2, String>

The values an arg is given after the sample's: its later one_of values, else false for a negatable flag and true for an as_bool value.

def given_samples source · line 5128 · raw

@values:List<&2, String> -> @+id:String -> @+rest:List<&2, Field> -> List<&2, List<&2, Field>>

rest after the arg given each of values in turn.

def absent_sample source · line 5135 · raw

@absent:Bool -> @id:String -> @rest:List<&2, Field> -> List<&2, List<&2, Field>>

def default_states source · line 5144 · raw

@found:Maybe<&2, String> -> @+id:String -> @+kind:UsageKind -> @+attrs:List<&2, Item> -> @+rest:List<&2, Field> -> List<&2, List<&2, Field>>

rest after each other state of an arg (§6.6): left out unless it is always present, then given each value after the sample's; with a default, given the sample's value too.

def info_states source · line 5156 · raw

@info:ArgInfo -> @+rest:List<&2, Field> -> List<&2, List<&2, Field>>

def after_fields source · line 5162 · raw

@samples:List<&2, List<&2, Field>> -> @+fields:List<&2, Field> -> List<&2, List<&2, Field>>

def arg_states source · line 5170 · raw

@items:List<&2, Item> -> List<&2, List<&2, Field>>

The sample's fields with one arg in turn in each of its other states.

def wrap_samples source · line 5181 · raw

@samples:List<&2, List<&2, Field>> -> @+c:Cmd -> @+path:List<&2, String> -> List<&2, Matches>

def state_fields source · line 5188 · raw

@c:Cmd -> @path:List<&2, String> -> List<&2, List<&2, Field>>

def samples source · line 5195 · raw

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

What check runs the decoder on at path: the sample, then each other state of each arg in scope, the rest as in the sample.

def sub_paths source · line 5199 · raw

@items:List<&2, Item> -> @+prefix:List<&2, String> -> List<&2, List<&2, String>>

The paths below prefix that can complete, in pre-order, without built-ins.

def sample_paths source · line 5213 · raw

@c:Cmd -> List<&2, List<&2, String>>

def bug_msg source · line 5220 · raw

@-A:Type -> @d:Dec(A) -> List<&2, String>

def distinct source · line 5234 · raw

@names:List<&2, String> -> @kept:List<&2, String> -> List<&2, String>

kept, then each name not yet in it.

def decode_bugs source · line 5240 · raw

@msgs:List<&2, String> -> @+at:String -> List<&2, Problem>

def cmd_name source · line 5245 · raw

@c:Cmd -> String

def host_tty source · line 5269 · raw

@h:Host -> @out:Bool -> @err:Bool -> Host

def color_attrs source · line 5274 · raw

@attrs:List<&2, Item> -> Bool

Rules 1 and 2 apply only to color() exactly as declared.

def is_color source · line 5281 · raw

@item:Item -> Bool

def has_color source · line 5288 · raw

@items:List<&2, Item> -> Bool

def color_seek source · line 5300 · raw

@dash:Bool -> @bare:Bool -> @attached:Bool -> @token:String -> @last:Maybe<&2, String> -> Prescan

def color_want source · line 5308 · raw

@hyphen:Bool -> @+token:String -> Prescan

def color_step source · line 5315 · raw

@state:Prescan -> @+token:String -> Prescan

def color_scan source · line 5323 · raw

@argv:List<&2, String> -> @state:Prescan -> Prescan

def color_word source · line 5328 · raw

@always:Bool -> @never:Bool -> Maybe<&2, Bool>

def color_value source · line 5334 · raw

@found:Maybe<&2, String> -> Maybe<&2, Bool>

def color_pick source · line 5340 · raw

@state:Prescan -> Maybe<&2, Bool>

def color_flag source · line 5346 · raw

@enabled:Bool -> @argv:List<&2, String> -> Maybe<&2, Bool>

def var_set source · line 5352 · raw

@found:Maybe<&2, String> -> Bool

An empty variable counts as unset.

def var_is source · line 5357 · raw

@found:Maybe<&2, String> -> @text:String -> Bool

def force_set source · line 5362 · raw

@found:Maybe<&2, String> -> Bool

def env_off source · line 5369 · raw

@off:Bool -> Maybe<&2, Bool>

def env_force source · line 5374 · raw

@force:Bool -> @+vars:List<&2, Var> -> Maybe<&2, Bool>

def env_rules source · line 5381 · raw

@no_color:Bool -> @+vars:List<&2, Var> -> Maybe<&2, Bool>

def env_color source · line 5388 · raw

@+vars:List<&2, Var> -> Maybe<&2, Bool>

Rules 3-6; None leaves rule 7, each stream's TTY.

def term_env source · line 5391 · raw

@found:Maybe<&2, Bool> -> @out_tty:Bool -> @err_tty:Bool -> @width:Nat -> Term

def term_for source · line 5397 · raw

@flag:Maybe<&2, Bool> -> @vars:List<&2, Var> -> @out_tty:Bool -> @err_tty:Bool -> @width:Nat -> Term

def term source · line 5403 · raw

@c:Cmd -> @h:Host -> @argv:List<&2, String> -> Term

def plain source · line 5411 · raw

@text:String -> Segment

def page_width source · line 5414 · raw

@width:Nat -> Nat

def summary source · line 5418 · raw

@s:String -> String

The first paragraph: the text before the first blank line.

def shown_text source · line 5424 · raw

@long:Bool -> @text:String -> String

def filled source · line 5429 · raw

@s:String -> Bool

def join_filled source · line 5432 · raw

@parts:List<&2, String> -> String

def find_command source · line 5441 · raw

@items:List<&2, Item> -> @+query:String -> @found:Maybe<&2, Item> -> Maybe<&2, Item>

def view_enter source · line 5453 · raw

@found:Maybe<&2, Item> -> @path:String -> @about:String -> @items:List<&2, Item> -> @globals:List<&2, Item> -> @root:Bool -> View

def view_step source · line 5461 · raw

@view:View -> @step:String -> View

def view_walk source · line 5469 · raw

@steps:List<&2, String> -> @view:View -> View

def view_of source · line 5474 · raw

@c:Cmd -> @path:List<&2, String> -> View

def arg_pos source · line 5479 · raw

@usage:String -> Bool

def has_plain_option source · line 5482 · raw

@items:List<&2, Item> -> Bool

def required_elem source · line 5491 · raw

@required:Bool -> @usage:String -> @attrs:List<&2, Item> -> List<&2, Segment>

def required_options source · line 5497 · raw

@items:List<&2, Item> -> List<&2, Segment>

def group_elem source · line 5507 · raw

@listed:Bool -> @args:List<&2, Item> -> @group:String -> List<&2, Segment>

def group_elems source · line 5514 · raw

@items:List<&2, Item> -> @+args:List<&2, Item> -> @+done:List<&2, String> -> List<&2, Segment>

Each need_one group of items, over args, that done does not name yet.

def positional_elems source · line 5525 · raw

@items:List<&2, Item> -> List<&2, Segment>

def command_elems source · line 5533 · raw

@subs:Bool -> @need:Bool -> List<&2, Segment>

def options_elem source · line 5539 · raw

@present:Bool -> List<&2, Segment>

def usage_elems source · line 5546 · raw

@path:String -> @+items:List<&2, Item> -> @+globals:List<&2, Item> -> List<&2, Segment>

The path, [OPTIONS], required options, need_one groups as E06 writes them, positionals, then the subcommand slot.

def segment_texts source · line 5559 · raw

@segs:List<&2, Segment> -> List<&2, String>

def usage_view source · line 5564 · raw

@view:View -> String

def usage source · line 5569 · raw

@c:Cmd -> @path:List<&2, String> -> String

def usage_rest source · line 5573 · raw

@elems:List<&2, Segment> -> @+w:Nat -> @+col:Nat -> List<&2, Segment>

Usage wraps between elements and continues at column 7.

def usage_block source · line 5584 · raw

@elems:List<&2, Segment> -> @w:Nat -> List<&2, Segment>

def tag source · line 5599 · raw

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

def maybe_list source · line 5605 · raw

@found:Maybe<&2, String> -> List<&2, String>

def list_or_none source · line 5610 · raw

@found:Maybe<&2, List<&2, String>> -> List<&2, String>

def right_text source · line 5615 · raw

@long:Bool -> @help:String -> @+attrs:List<&2, Item> -> String

def bold_names source · line 5624 · raw

@names:List<&2, String> -> @first:Bool -> List<&2, Segment>

def value_cut source · line 5633 · raw

@s:String -> Nat

Where an option's value or repeat starts: " <", "[=", or a final "...".

def option_left source · line 5642 · raw

@+usage:String -> List<&2, Segment>

Option names bold; separators, value and repeat plain.

def arg_row source · line 5648 · raw

@parsed:Usage -> @usage:String -> @help:String -> @attrs:List<&2, Item> -> @long:Bool -> Row

def find_heading source · line 5657 · raw

@attrs:List<&2, Item> -> String

def option_row source · line 5663 · raw

@shown:Bool -> @+usage:String -> @help:String -> @attrs:List<&2, Item> -> @long:Bool -> List<&2, Row>

def option_rows source · line 5670 · raw

@items:List<&2, Item> -> @+long:Bool -> @+heading:String -> List<&2, Row>

The visible options under a heading, "" for Options.

def positional_row source · line 5683 · raw

@shown:Bool -> @usage:String -> @help:String -> @attrs:List<&2, Item> -> @long:Bool -> List<&2, Row>

def positional_rows source · line 5690 · raw

@items:List<&2, Item> -> @+long:Bool -> List<&2, Row>

def command_row source · line 5700 · raw

@hidden:Bool -> @name:String -> @about:String -> @children:List<&2, Item> -> List<&2, Row>

def command_rows source · line 5708 · raw

@items:List<&2, Item> -> List<&2, Row>

def help_sub_row source · line 5717 · raw

@present:Bool -> List<&2, Row>

def builtin_row source · line 5725 · raw

@taken:Bool -> @short:String -> @long:String -> @text:String -> Row

A built-in option row, without its short when an app arg took it.

def help_text source · line 5732 · raw

@differs:Bool -> @long:Bool -> String

def version_row source · line 5738 · raw

@present:Bool -> @args:List<&2, Item> -> List<&2, Row>

def heading_titles source · line 5746 · raw

@items:List<&2, Item> -> @+seen:List<&2, String> -> List<&2, String>

Headings of visible args, in order of first use.

def heading_sections source · line 5758 · raw

@titles:List<&2, String> -> @+args:List<&2, Item> -> @+long:Bool -> List<&2, Section>

def args_paragraphs source · line 5767 · raw

@items:List<&2, Item> -> Bool

Whether a visible arg's help has more than one paragraph.

def indent_cell source · line 5775 · raw

@indent:Bool -> @left:List<&2, Segment> -> List<&2, Segment>

def row_cell source · line 5781 · raw

@row:Row -> @shorted:Bool -> List<&2, Segment>

A left cell; long-only options indent 4 more on a page with a short.

def cell_width source · line 5786 · raw

@cell:List<&2, Segment> -> Nat

def row_short source · line 5791 · raw

@row:Row -> Bool

def any_short source · line 5795 · raw

@rows:List<&2, Row> -> Bool

def widest source · line 5801 · raw

@rows:List<&2, Row> -> @+shorted:Bool -> @+k:Nat -> @+best:Nat -> Nat

L, the widest left cell w with 2 + w + 2 <= K.

def pad_line source · line 5809 · raw

@line:String -> @col:Nat -> String

def pad_lines source · line 5815 · raw

@lines:List<&2, String> -> @+col:Nat -> List<&2, Segment>

def first_then source · line 5820 · raw

@lines:List<&2, String> -> @col:Nat -> List<&2, Segment>

def row_form source · line 5827 · raw

@fits:Bool -> @cell:List<&2, Segment> -> @lw:Nat -> @right:String -> @w:Nat -> @+c:Nat -> List<&2, Segment>

A cell that fits takes its text after padding to C; one that does not stands alone, its text on the next lines at max(C, 10).

def row_lines source · line 5839 · raw

@row:Row -> @shorted:Bool -> @w:Nat -> @k:Nat -> @c:Nat -> List<&2, Segment>

def rows_lines source · line 5847 · raw

@rows:List<&2, Row> -> @+shorted:Bool -> @+w:Nat -> @+k:Nat -> @+c:Nat -> List<&2, Segment>

def section_rows source · line 5855 · raw

@sections:List<&2, Section> -> List<&2, Row>

def section_blocks source · line 5861 · raw

@sections:List<&2, Section> -> @+shorted:Bool -> @+w:Nat -> @+k:Nat -> @+c:Nat -> List<&2, List<&2, Segment>>

def sections_blocks source · line 5872 · raw

@+sections:List<&2, Section> -> @+w:Nat -> List<&2, List<&2, Segment>>

One column for the page: C = L + 4, with K = 2W/5.

def text_block source · line 5880 · raw

@text:String -> @w:Nat -> List<&2, List<&2, Segment>>

def example_lines source · line 5885 · raw

@items:List<&2, Item> -> List<&2, Segment>

def examples_block source · line 5893 · raw

@lines:List<&2, Segment> -> List<&2, List<&2, Segment>>

def after_texts source · line 5898 · raw

@items:List<&2, Item> -> List<&2, String>

def more_blocks source · line 5904 · raw

@blocks:List<&2, List<&2, Segment>> -> List<&2, Segment>

def join_blocks source · line 5911 · raw

@blocks:List<&2, List<&2, Segment>> -> List<&2, Segment>

Blocks apart by one blank line; the page ends with a newline.

def help_page source · line 5916 · raw

@view:View -> @+long:Bool -> @+w:Nat -> List<&2, Segment>

def help_out source · line 5939 · raw

@t:Term -> @view:View -> @long:Bool -> String

def help source · line 5945 · raw

@+c:Cmd -> @path:List<&2, String> -> @long:Bool -> @h:Host -> String

The help page for the longest valid prefix of path, in stdout's colors.

def row_zero source · line 5953 · raw

@b:String -> @+k:Nat -> List<&2, Nat>

def head_nat source · line 5958 · raw

@xs:List<&2, Nat> -> Nat

def tail_nats source · line 5963 · raw

@xs:List<&2, Nat> -> List<&2, Nat>

def same_char source · line 5968 · raw

@found:Maybe<&2, Char> -> @c:Char -> Bool

def osa_row source · line 5975 · raw

@bs:String -> @bp:Maybe<&2, Char> -> @+a:Char -> @+ap:Maybe<&2, Char> -> @+up:List<&2, Nat> -> @+up2:List<&2, Nat> -> @left:Nat -> List<&2, Nat>

Row i of optimal string alignment for a[i]: up starts at d[i-1][j-1], up2 at d[i-2][j-2], and left is d[i][j-1].

def osa_rows source · line 5989 · raw

@s:String -> @ap:Maybe<&2, Char> -> @+i:Nat -> @+b:String -> @+prev:List<&2, Nat> -> @prev2:List<&2, Nat> -> List<&2, Nat>

def last_nat source · line 5997 · raw

@xs:List<&2, Nat> -> @last:Nat -> Nat

def osa source · line 6002 · raw

@a:String -> @+b:String -> Nat

def undashed source · line 6006 · raw

@s:String -> String

def scored source · line 6011 · raw

@names:List<&2, String> -> @+typed:String -> @+limit:Nat -> List<&2, Scored>

def at_distance source · line 6021 · raw

@found:List<&2, Scored> -> @+d:Nat -> List<&2, String>

def by_distance source · line 6028 · raw

@levels:Nat -> @+d:Nat -> @+found:List<&2, Scored> -> List<&2, String>

def suggest source · line 6040 · raw

@+typed:String -> @names:List<&2, String> -> List<&2, String>

At most 3 names within max(1, n / 3) edits, by distance, then order. key is bound because a temporary argument makes String.length take its string, adding a keep to each caller that reuses one (Nat.read.fits, arg_display).

def quoted source · line 6048 · raw

@text:String -> @styles:List<&2, Style> -> List<&2, Segment>

def missing_lines source · line 6051 · raw

@missing:List<&2, String> -> String

def visible_subs source · line 6056 · raw

@items:List<&2, Item> -> List<&2, String>

def fault_message source · line 6064 · raw

@fault:ScanFault -> @path:String -> @items:List<&2, Item> -> List<&2, Segment>

def green_names source · line 6106 · raw

@names:List<&2, String> -> @first:Bool -> List<&2, Segment>

def tip source · line 6114 · raw

@text:String -> List<&2, List<&2, Segment>>

def similar source · line 6118 · raw

@kind:String -> @found:List<&2, String> -> List<&2, List<&2, Segment>>

T4: one suggestion or several.

def long_name source · line 6129 · raw

@s:String -> Bool

def option_names source · line 6132 · raw

@parsed:Usage -> @attrs:List<&2, Item> -> List<&2, String>

def visible_names source · line 6144 · raw

@hidden:Bool -> @usage:String -> @attrs:List<&2, Item> -> List<&2, String>

def long_candidates source · line 6151 · raw

@items:List<&2, Item> -> List<&2, String>

T4 for E01: visible longs, their no- forms and long aliases.

def sub_candidates source · line 6160 · raw

@items:List<&2, Item> -> List<&2, String>

T4 for E02: visible subcommand names and aliases, then help.

def display_choices source · line 6171 · raw

@items:List<&2, Item> -> @+arg:String -> @found:List<&2, String> -> List<&2, String>

T4 for E04: the one_of values of the arg E04 names.

def owned source · line 6182 · raw

@found:Maybe<&2, OptFound> -> @text:String -> Maybe<&2, String>

def owned_by source · line 6187 · raw

@hit:Maybe<&2, OptFound> -> @token:String -> @prefix:String -> @step:String -> @found:Maybe<&2, String> -> Maybe<&2, String>

def owner source · line 6196 · raw

@path:List<&2, String> -> @+items:List<&2, Item> -> @+prefix:String -> @+token:String -> @+long:String -> @found:Maybe<&2, String> -> Maybe<&2, String>

T1: the deepest ancestor whose args take the long, and its child on path.

def descendant source · line 6207 · raw

@items:List<&2, Item> -> @+prefix:String -> @+long:String -> @found:Maybe<&2, String> -> Maybe<&2, String>

T2: the first subcommand in pre-order whose args take the long.

def maybe_tip source · line 6218 · raw

@found:Maybe<&2, String> -> List<&2, List<&2, Segment>>

def belongs source · line 6223 · raw

@found:Maybe<&2, String> -> @token:String -> List<&2, List<&2, Segment>>

def sub_exists source · line 6230 · raw

@found:Maybe<&2, SubFound> -> @name:String -> List<&2, List<&2, Segment>>

def before_eq source · line 6238 · raw

@s:String -> String

def long_tips source · line 6245 · raw

@is_long:Bool -> @+token:String -> @root:String -> @path:List<&2, String> -> @+items:List<&2, Item> -> @root_items:List<&2, Item> -> @here:String -> List<&2, List<&2, Segment>>

T1, T2 and T3, for E01 on a long; --name=value looks up --name.

def operand_count source · line 6260 · raw

@events:List<&2, ScanEvent> -> @count:Nat -> Nat

def trace_operands source · line 6267 · raw

@trace:ScanTrace -> Nat

def dash_slot source · line 6272 · raw

@open:Bool -> @+token:String -> List<&2, List<&2, Segment>>

def dash_tip source · line 6281 · raw

@hyphen:Bool -> @token:String -> @items:List<&2, Item> -> @c:Cmd -> @argv:List<&2, String> -> List<&2, List<&2, Segment>>

T5: a hyphen token that the next positional slot could take after --; only then is argv scanned again to count the operands in scope.

def cmd_items source · line 6289 · raw

@c:Cmd -> List<&2, Item>

def fault_tips source · line 6294 · raw

@fault:ScanFault -> @+c:Cmd -> @+path:List<&2, String> -> @argv:List<&2, String> -> @here:String -> @+items:List<&2, Item> -> @globals:List<&2, Item> -> List<&2, List<&2, Segment>>

Every tip that applies, in table order.

def tip_spans source · line 6318 · raw

@tips:List<&2, List<&2, Segment>> -> List<&2, Segment>

def tip_block source · line 6326 · raw

@tips:List<&2, List<&2, Segment>> -> List<&2, Segment>

def error_page source · line 6331 · raw

@message:List<&2, Segment> -> @tips:List<&2, List<&2, Segment>> -> @usage:List<&2, Segment> -> List<&2, Segment>

def fault_view source · line 6341 · raw

@view:View -> @+fault:ScanFault -> @c:Cmd -> @path:List<&2, String> -> @argv:List<&2, String> -> @w:Nat -> List<&2, Segment>

def fault_err source · line 6350 · raw

@t:Term -> @fault:ScanFault -> @+c:Cmd -> @+path:List<&2, String> -> @argv:List<&2, String> -> String

An error at the scope where scanning stopped, in stderr's colors.

def unknown_text source · line 6361 · raw

@c:Cmd -> @path:List<&2, String> -> @name:String -> @t:Term -> String

The E02 page eval prints for an unknown subcommand name at path, with its similar names and the scope's usage, in t's stderr colors and width. An app with external() prints it, and exits usage_code(c) as eval does, when no plugin answers to name.

def summary_err source · line 6365 · raw

@t:Term -> @view:View -> String

def problem_line source · line 6372 · raw

@p:Problem -> String

def problem_lines source · line 6412 · raw

@found:List<&2, Problem> -> String

def sh_body source · line 6424 · raw

@s:String -> String

def Sh.quote source · line 6431 · raw

@s:String -> String

POSIX single quotes, with ' written as '\'' (P3).

def fish_body source · line 6434 · raw

@s:String -> String

def Fish.quote source · line 6442 · raw

@s:String -> String

fish single quotes, with \ and ' backslash-escaped (P4).

def Zsh.esc source · line 6447 · raw

@s:String -> String

Text in an _arguments spec or a _describe entry, with \, [, ] and : backslash-escaped (P5).

def roff_body source · line 6458 · raw

@s:String -> @start:Bool -> String

Text for man(7), start telling whether a line starts here: \, -, ", ' and ` as escapes, and \& before a . or a space that starts a line.

def Roff.esc source · line 6472 · raw

@s:String -> String

Text that starts lines (P6, P15).

def roff_text source · line 6476 · raw

@s:String -> String

Text after the start of a line.

def text_lines source · line 6479 · raw

@lines:List<&2, String> -> String

def one_line source · line 6485 · raw

@s:String -> String

The summary with its hard line breaks as spaces.

def ident_char source · line 6488 · raw

@+c:Char -> Char

def ident source · line 6492 · raw

@s:String -> String

A name with every char outside [A-Za-z0-9_] as _, for shell identifiers.

def same_words source · line 6497 · raw

@a:List<&2, String> -> @b:List<&2, String> -> Bool

def last_with source · line 6503 · raw

@lines:List<&2, String> -> @+suffix:String -> List<&2, String>

def places source · line 6516 · raw

@items:List<&2, Item> -> @+words:List<&2, String> -> @+globals:List<&2, Item> -> List<&2, Place>

The visible commands below items, whose subcommands inherit globals.

def all_places source · line 6529 · raw

@+items:List<&2, Item> -> List<&2, Place>

def list_number source · line 6556 · raw

@lists:List<&2, List<&2, String>> -> @+values:List<&2, String> -> @hit:Bool -> @+k:Nat -> Nat

The number of values in lists, counting from k + 1 after a miss, or 0.

def add_list source · line 6564 · raw

@found:Maybe<&2, List<&2, String>> -> @+lists:List<&2, List<&2, String>> -> List<&2, List<&2, String>>

def visible_one_of source · line 6573 · raw

@hidden:Bool -> @attrs:List<&2, Item> -> Maybe<&2, List<&2, String>>

def item_lists source · line 6579 · raw

@items:List<&2, Item> -> @lists:List<&2, List<&2, String>> -> List<&2, List<&2, String>>

def place_lists source · line 6588 · raw

@places:List<&2, Place> -> @lists:List<&2, List<&2, String>> -> List<&2, List<&2, String>>

The one_of lists of visible args, each once, in pre-order.

def type_comp source · line 6595 · raw

@found:Maybe<&2, ValueType> -> Comp

def comp_of source · line 6601 · raw

@found:Maybe<&2, List<&2, String>> -> @t:Maybe<&2, ValueType> -> @lists:List<&2, List<&2, String>> -> Comp

def head_part source · line 6607 · raw

@parts:List<&2, String> -> String

def next_part source · line 6612 · raw

@parts:List<&2, String> -> String

def between source · line 6617 · raw

@s:String -> @+open:Char -> @close:Char -> String

def placeholder source · line 6621 · raw

@+usage:String -> String

The name in a usage's <>, or in an optional positional's [].

def short_alias source · line 6625 · raw

@s:String -> Bool

def short_names source · line 6628 · raw

@parsed:Usage -> @attrs:List<&2, Item> -> List<&2, String>

def parsed_kind source · line 6636 · raw

@parsed:Usage -> UsageKind

def arg_opt source · line 6641 · raw

@+parsed:Usage -> @usage:String -> @help:String -> @+attrs:List<&2, Item> -> @lists:List<&2, List<&2, String>> -> Opt

def arg_opts source · line 6649 · raw

@items:List<&2, Item> -> @+lists:List<&2, List<&2, String>> -> List<&2, Opt>

The visible options in items.

def flag_opt source · line 6661 · raw

@names:List<&2, String> -> @help:String -> Opt

def version_opts source · line 6664 · raw

@present:Bool -> @args:List<&2, Item> -> List<&2, Opt>

def builtin_opts source · line 6674 · raw

@+items:List<&2, Item> -> @globals:List<&2, Item> -> @root:Bool -> List<&2, Opt>

-h and --help, without -h when an arg took it, then at a root with a version -V and --version likewise.

def pos_slot source · line 6682 · raw

@parsed:Usage -> @k:Nat -> @usage:String -> @+attrs:List<&2, Item> -> @lists:List<&2, List<&2, String>> -> List<&2, Slot>

def arg_slots source · line 6691 · raw

@items:List<&2, Item> -> @+k:Nat -> @+lists:List<&2, List<&2, String>> -> List<&2, Slot>

The positional slots in items, hidden ones too, numbered from k.

def completing source · line 6703 · raw

@slots:List<&2, Slot> -> List<&2, Slot>

The slots up to the variadic one, which takes every later value.

def variadic source · line 6710 · raw

@slots:List<&2, Slot> -> Maybe<&2, Slot>

def sub_entries source · line 6718 · raw

@items:List<&2, Item> -> List<&2, Entry>

The visible subcommands in items.

def opt_names source · line 6727 · raw

@opts:List<&2, Opt> -> List<&2, String>

def entry_names source · line 6733 · raw

@entries:List<&2, Entry> -> List<&2, String>

def stop_of source · line 6745 · raw

@place:Place -> @k:Nat -> @+lists:List<&2, List<&2, String>> -> Stop

def stops source · line 6754 · raw

@places:List<&2, Place> -> @+k:Nat -> @+lists:List<&2, List<&2, String>> -> List<&2, Stop>

def stop_number source · line 6762 · raw

@stops:List<&2, Stop> -> @+words:List<&2, String> -> @found:Maybe<&2, Nat> -> Nat

The number of the stop at words, from found on.

def sh_list source · line 6774 · raw

@words:List<&2, String> -> @+sep:String -> String

Words quoted for sh, apart by sep.

def dests source · line 6780 · raw

@names:List<&2, String> -> @+dest:String -> List<&2, String>

def entry_dests source · line 6786 · raw

@entries:List<&2, Entry> -> @+words:List<&2, String> -> List<&2, String>

Each subcommand name's path, once per name.

def bash_subs source · line 6795 · raw

@+entries:List<&2, Entry> -> @words:List<&2, String> -> List<&2, String>

def bash_shape source · line 6803 · raw

@found:Maybe<&2, Slot> -> List<&2, String>

def bash_scope_arm source · line 6810 · raw

@stop:Stop -> List<&2, String>

def bash_letter source · line 6821 · raw

@comp:Comp -> String

def bash_values source · line 6828 · raw

@comp:Comp -> String

def bash_kind source · line 6833 · raw

@+comp:Comp -> @bare:Bool -> String

def bash_opt_case source · line 6837 · raw

@opt:Opt -> List<&2, String>

def bash_opt_cases source · line 6847 · raw

@opts:List<&2, Opt> -> List<&2, String>

def bash_slot_cases source · line 6852 · raw

@slots:List<&2, Slot> -> List<&2, String>

def bash_cases source · line 6864 · raw

@words:List<&2, String> -> @cases:List<&2, String> -> List<&2, String>

def bash_arg_arm source · line 6876 · raw

@stop:Stop -> List<&2, String>

def bash_engine source · line 6889 · raw

@+id:String -> @name:String -> List<&2, String>

The rest of every bash script, for function prefix id and the quoted command name: the parser of COMP_WORDS, then the binding.

def bash_script source · line 6997 · raw

@+name:String -> @+items:List<&2, Item> -> String

def zsh_action source · line 7028 · raw

@comp:Comp -> String

def zsh_pre source · line 7037 · raw

@kind:UsageKind -> @+names:List<&2, String> -> String

The prefix of an option's specs: * when it repeats, else its names as a group that excludes each other.

def zsh_spec source · line 7045 · raw

@+name:String -> @kind:UsageKind -> @pre:String -> @d:String -> @ph:String -> @act:String -> String

def zsh_names source · line 7055 · raw

@names:List<&2, String> -> @+kind:UsageKind -> @+pre:String -> @+d:String -> @+ph:String -> @+act:String -> List<&2, String>

def zsh_opts source · line 7063 · raw

@opts:List<&2, Opt> -> List<&2, String>

def zsh_slots source · line 7072 · raw

@slots:List<&2, Slot> -> List<&2, String>

def zsh_spec_lines source · line 7086 · raw

@specs:List<&2, String> -> @+ind:String -> List<&2, String>

Specs quoted, one per line, all but the last continued.

def zsh_args source · line 7095 · raw

@+ind:String -> @specs:List<&2, String> -> List<&2, String>

def zsh_entry source · line 7098 · raw

@names:List<&2, String> -> @+ind:String -> @+about:String -> List<&2, String>

def zsh_entries source · line 7106 · raw

@entries:List<&2, Entry> -> @+ind:String -> List<&2, String>

def zsh_commands source · line 7113 · raw

@entries:List<&2, Entry> -> @with_help:Bool -> @label:String -> @+ind:String -> List<&2, String>

def zsh_label source · line 7126 · raw

@+name:String -> @words:List<&2, String> -> String

def zsh_deeper source · line 7129 · raw

@arms:List<&2, String> -> @+depth:Nat -> @+ind:String -> List<&2, String>

def zsh_help_tree source · line 7142 · raw

@entries:List<&2, Entry> -> @label:String -> @arms:List<&2, String> -> @+depth:Nat -> @+ind:String -> List<&2, String>

After help at depth, the subcommand names, then deeper by arms.

def bar_names source · line 7151 · raw

@names:List<&2, String> -> String

def zsh_help_arms source · line 7159 · raw

@items:List<&2, Item> -> @+name:String -> @+words:List<&2, String> -> @+depth:Nat -> @+ind:String -> List<&2, String>

The help tree's arms at ind for the subcommands in items that have subcommands of their own.

def zsh_past_end source · line 7179 · raw

@ind:String -> String

Ends a state that _arguments entered past a "--" it dropped, after which no subcommand follows.

def zsh_ends source · line 7184 · raw

@words:List<&2, String> -> @+ind:String -> List<&2, String>

At the top command (no words), the count of "--" before the cursor that zsh_past_end compares with.

def zsh_branch source · line 7196 · raw

@+entries:List<&2, Entry> -> @specs:List<&2, String> -> @+items:List<&2, Item> -> @+name:String -> @+words:List<&2, String> -> @arms:List<&2, String> -> @+ind:String -> List<&2, String>

The body of a command with subcommands: its specs end in a state that offers them, completes help's tree, or enters the arm of the one given.

def zsh_body source · line 7229 · raw

@entries:List<&2, Entry> -> @specs:List<&2, String> -> @+items:List<&2, Item> -> @+lists:List<&2, List<&2, String>> -> @name:String -> @words:List<&2, String> -> @arms:List<&2, String> -> @ind:String -> List<&2, String>

def zsh_cmd source · line 7242 · raw

@+items:List<&2, Item> -> @+globals:List<&2, Item> -> @+lists:List<&2, List<&2, String>> -> @name:String -> @+words:List<&2, String> -> @arms:List<&2, String> -> @ind:String -> List<&2, String>

The body at ind of the command with items and globals at words, given the arms of its subcommands.

def zsh_arms source · line 7256 · raw

@items:List<&2, Item> -> @+globals:List<&2, Item> -> @+lists:List<&2, List<&2, String>> -> @+name:String -> @+words:List<&2, String> -> @+ind:String -> List<&2, String>

The arms at ind for the visible subcommands in items, which inherit globals; their bodies are 2 deeper.

def zsh_lists source · line 7274 · raw

@lists:List<&2, List<&2, String>> -> @+k:Nat -> List<&2, String>

def zsh_arrays source · line 7282 · raw

@lists:List<&2, List<&2, String>> -> List<&2, String>

def zsh_script source · line 7289 · raw

@+name:String -> @+items:List<&2, Item> -> String

def fish_list source · line 7312 · raw

@words:List<&2, String> -> String

Words quoted for fish, apart by spaces.

def fish_pats source · line 7318 · raw

@names:List<&2, String> -> @+pre:String -> List<&2, String>

def fish_dest_arms source · line 7325 · raw

@entries:List<&2, Entry> -> @+pre:String -> @+words:List<&2, String> -> @+found:List<&2, Stop> -> List<&2, String>

The arms of _dest for subcommands entries of the path at words, numbered pre.

def fish_dests source · line 7335 · raw

@stops:List<&2, Stop> -> @+found:List<&2, Stop> -> List<&2, String>

def valued_names source · line 7344 · raw

@opts:List<&2, Opt> -> List<&2, String>

def fish_valued_arm source · line 7351 · raw

@k:Nat -> @names:List<&2, String> -> List<&2, String>

def fish_valued source · line 7359 · raw

@stop:Stop -> List<&2, String>

def slot_shape source · line 7364 · raw

@found:Maybe<&2, Slot> -> String

def fish_shape_arm source · line 7370 · raw

@shown:Bool -> @k:Nat -> @has:Bool -> @found:Maybe<&2, Slot> -> List<&2, String>

def fish_shape source · line 7379 · raw

@stop:Stop -> List<&2, String>

def fish_values source · line 7387 · raw

@lists:List<&2, List<&2, String>> -> @+k:Nat -> List<&2, String>

def fish_values_fn source · line 7396 · raw

@+id:String -> @lists:List<&2, List<&2, String>> -> List<&2, String>

def fish_flag source · line 7408 · raw

@long:Bool -> @name:String -> String

def fish_flags source · line 7413 · raw

@names:List<&2, String> -> List<&2, String>

def fish_words source · line 7419 · raw

@+id:String -> @comp:Comp -> String

What completes a value comp offers: words, files, directories or none.

def fish_needs source · line 7427 · raw

@comp:Comp -> String

def fish_kind source · line 7434 · raw

@kind:UsageKind -> @+id:String -> @+comp:Comp -> String

An option of kind needs its value (-r), and only a file name may be any word (-x elsewhere); a [=<V>] value is optional.

def fish_opt_lines source · line 7441 · raw

@opts:List<&2, Opt> -> @+at:String -> @+id:String -> List<&2, String>

def fish_builtin_lines source · line 7451 · raw

@opts:List<&2, Opt> -> @+at:String -> @tags:String -> List<&2, String>

The built-ins, help first, which also holds after help (h).

def fish_name_lines source · line 7459 · raw

@names:List<&2, String> -> @+at:String -> @+about:String -> List<&2, String>

def fish_sub_lines source · line 7467 · raw

@entries:List<&2, Entry> -> @+at:String -> List<&2, String>

def fish_slot_lines source · line 7474 · raw

@slots:List<&2, Slot> -> @+at:String -> @+id:String -> List<&2, String>

def fish_ends source · line 7486 · raw

@subs:List<&2, Entry> -> @+at:String -> @id:String -> @slots:List<&2, Slot> -> List<&2, String>

def fish_lines source · line 7494 · raw

@stops:List<&2, Stop> -> @+pre:String -> @+id:String -> List<&2, String>

def fish_engine source · line 7509 · raw

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

The function every fish script shares, for function prefix id: it walks the words before the cursor as the bash engine does.

def fish_script source · line 7578 · raw

@+name:String -> @+items:List<&2, Item> -> String

def roff_bold source · line 7617 · raw

@s:String -> String

def roff_bolds source · line 7620 · raw

@names:List<&2, String> -> List<&2, String>

def roff_texts source · line 7625 · raw

@texts:List<&2, String> -> List<&2, String>

def spaces_only source · line 7630 · raw

@s:String -> Bool

def line_mark source · line 7636 · raw

@blank:Bool -> @line:String -> List<&2, Maybe<&2, String>>

def para_marks source · line 7643 · raw

@lines:List<&2, String> -> List<&2, Maybe<&2, String>>

Each line, None for an empty one, which ends a paragraph; a line of only spaces is left out.

def roff_marks source · line 7653 · raw

@marks:List<&2, Maybe<&2, String>> -> @+sep:String -> @gap:Maybe<&2, String> -> List<&2, String>

Marked lines escaped, after gap: nothing before the first, .br within a paragraph, sep between paragraphs.

def roff_paras source · line 7664 · raw

@text:String -> @sep:String -> List<&2, String>

def ph_end source · line 7667 · raw

@s:String -> Nat

def roff_ph source · line 7674 · raw

@+s:String -> String

A placeholder's name in italics, from after its <.

def roff_value source · line 7679 · raw

@rest:String -> String

def roff_option source · line 7688 · raw

@+usage:String -> String

Option names bold, the placeholder in italics.

def roff_positional source · line 7694 · raw

@+usage:String -> String

A positional in italics, apart from its repeat.

def roff_entry source · line 7699 · raw

@left:String -> @help:String -> @attrs:List<&2, Item> -> List<&2, String>

def roff_positional_entry source · line 7703 · raw

@shown:Bool -> @usage:String -> @help:String -> @attrs:List<&2, Item> -> List<&2, String>

def roff_positionals source · line 7709 · raw

@items:List<&2, Item> -> List<&2, String>

def roff_option_entry source · line 7719 · raw

@shown:Bool -> @usage:String -> @help:String -> @attrs:List<&2, Item> -> List<&2, String>

def roff_options source · line 7726 · raw

@items:List<&2, Item> -> @+heading:String -> List<&2, String>

The visible options under a heading, "" for OPTIONS.

def roff_builtins source · line 7737 · raw

@opts:List<&2, Opt> -> List<&2, String>

def roff_headings source · line 7744 · raw

@titles:List<&2, String> -> @+args:List<&2, Item> -> List<&2, String>

def roff_command source · line 7753 · raw

@hidden:Bool -> @+page:String -> @name:String -> @about:String -> @children:List<&2, Item> -> List<&2, String>

def roff_commands source · line 7762 · raw

@items:List<&2, Item> -> @+page:String -> List<&2, String>

def roff_arg source · line 7771 · raw

@pos:Bool -> @+usage:String -> @attrs:List<&2, Item> -> String

def roff_env_names source · line 7776 · raw

@names:List<&2, String> -> List<&2, String>

def roff_env_order source · line 7782 · raw

@rest:List<&2, String> -> String

How a variable after the first is read, if there is one.

def roff_env source · line 7787 · raw

@hidden:Bool -> @names:List<&2, String> -> @+usage:String -> @attrs:List<&2, Item> -> List<&2, String>

def roff_envs source · line 7796 · raw

@items:List<&2, Item> -> List<&2, String>

def roff_examples source · line 7805 · raw

@items:List<&2, Item> -> @before:List<&2, String> -> List<&2, String>

def sub_pages source · line 7818 · raw

@items:List<&2, Item> -> @+page:String -> List<&2, String>

def init_words source · line 7827 · raw

@words:List<&2, String> -> List<&2, String>

def parent_pages source · line 7834 · raw

@words:List<&2, String> -> List<&2, String>

The parent's page, none at the root.

def roff_refs source · line 7840 · raw

@pages:List<&2, String> -> List<&2, String>

def roff_see source · line 7845 · raw

@pages:List<&2, String> -> List<&2, String>

def roff_synopsis source · line 7850 · raw

@texts:List<&2, String> -> String

def roff_section source · line 7855 · raw

@title:String -> @lines:List<&2, String> -> List<&2, String>

def roff_view source · line 7860 · raw

@view:View -> @title:String -> String

def find_version source · line 7891 · raw

@items:List<&2, Item> -> String

def roff source · line 7898 · raw

@c:Cmd -> @path:List<&2, String> -> String

The man page of the command at the longest valid prefix of path (§11).

def script source · line 7905 · raw

@c:Cmd -> @s:Shell -> String

The completion script for shell s (§11).

def status_code source · line 7914 · raw

@items:List<&2, Item> -> U32

The code of the first usage_status among items when it fits, else 2.

def usage_code source · line 7921 · raw

@c:Cmd -> U32

The exit status of c's usage errors: its root's usage_status, else 2.

def sub_at source · line 7930 · raw

@path:List<&2, String> -> @items:List<&2, Item> -> @found:Maybe<&2, SubFound> -> Maybe<&2, SubFound>

The subcommand at path, from found on.

def builtin_name source · line 7938 · raw

@found:Maybe<&2, SubFound> -> Maybe<&2, String>

def field_values source · line 7944 · raw

@f:Field -> List<&2, String>

def shell_named source · line 7949 · raw

@+name:String -> Shell

The shell completions was given, which one_of limits to these three.

def builtin_page source · line 7953 · raw

@man:Bool -> @c:Cmd -> @fields:List<&2, Field> -> String

def outcome_accepted source · line 7962 · raw

@builtin:Maybe<&2, String> -> @c:Cmd -> @path:List<&2, String> -> @fields:List<&2, Field> -> @external:Maybe<&2, ExternalArgs> -> Outcome

V6: the completions built-in prints its script and man its page, plain; any other path is left to decode.

def outcome_parse source · line 7969 · raw

@result:ParseResult -> @+c:Cmd -> @h:Host -> @+argv:List<&2, String> -> Outcome

def outcome_lint source · line 7986 · raw

@found:List<&2, Problem> -> @+c:Cmd -> @+h:Host -> @+argv:List<&2, String> -> Outcome

def outcome source · line 7996 · raw

@+c:Cmd -> @h:Host -> @argv:List<&2, String> -> Outcome

eval through V6: a lint failure, help, version, the V3 summary, an error or a built-in's output is Shown; Matched is a parse left to decode.

def linted_found source · line 8003 · raw

@found:List<&2, Problem> -> @c:Cmd -> Result<&2, &2, List<&2, Problem>, Linted>

def linted source · line 8010 · raw

@+c:Cmd -> Result<&2, &2, List<&2, Problem>, Linted>

Lint c once: a Linted, or lint's problems in the order problems lists.

def outcome_linted source · line 8014 · raw

@l:Linted -> @+h:Host -> @+argv:List<&2, String> -> Outcome

outcome on a Linted's spec, without the lint.

def usage_err source · line 8026 · raw

@t:Term -> @msg:String -> @view:View -> String

E12: a decoder's Usage message as an error at the matched scope, printed as given, in stderr's colors.

def faulted source · line 8033 · raw

@-A:Type -> @f:Fault -> @+cmd:Cmd -> @path:List<&2, String> -> @h:Host -> @argv:List<&2, String> -> Step<A>

def decoded source · line 8042 · raw

@-A:Type -> @d:Dec(A) -> @cmd:Cmd -> @path:List<&2, String> -> @h:Host -> @argv:List<&2, String> -> Step<A>

V7: Done is Go with term's decisions; a fault exits 70 or usage_code.

def eval_step source · line 8048 · raw

@-A:Type -> @decode:(@+m:Matches -> Dec(A)) -> @o:Outcome -> @h:Host -> @argv:List<&2, String> -> Step<A>

def eval_with source · line 8057 · raw

@-A:Type -> @decode:(@+m:Matches -> Dec(A)) -> @c:Cmd -> @+h:Host -> @+argv:List<&2, String> -> Step<A>

eval with the decoder as a value, so a law can quantify over decoders.

def eval_linted_with source · line 8068 · raw

@-A:Type -> @decode:(@+m:Matches -> Dec(A)) -> @l:Linted -> @+h:Host -> @+argv:List<&2, String> -> Step<A>

eval_linted with the decoder as a value.

def env_names source · line 8080 · raw

@items:List<&2, Item> -> List<&2, String>

Each arg's env name in pre-order: an arg's own, then its subcommands'.

def vars source · line 8089 · raw

@c:Cmd -> List<&2, String>

def columns_ok source · line 8098 · raw

@+value:String -> Bool

COLUMNS sets the width when as_nat reads it and it is at least 1. digits is bound because a temporary argument makes String.is_empty take its string, adding a take to each caller that reuses one (valid_nat).

def columns_valid source · line 8102 · raw

@ok:Bool -> @value:String -> Maybe<&2, Nat>

def columns_width source · line 8107 · raw

@found:Maybe<&2, String> -> Maybe<&2, Nat>

def tty_columns source · line 8113 · raw

@out_tty:Bool -> @err_tty:Bool -> @out_cols:U32 -> @err_cols:U32 -> Nat

stdout's columns if it is a TTY, else stderr's if it is one, else 0.

def nonzero source · line 8121 · raw

@first:Nat -> @then:Nat -> Nat

first, unless it is 0.

def width_or source · line 8126 · raw

@found:Maybe<&2, Nat> -> @then:Nat -> Nat

def probe source · line 8133 · raw

@+vars:List<&2, Var> -> @+out_tty:Bool -> @+err_tty:Bool -> @out_cols:U32 -> @err_cols:U32 -> Host

§7.3: the host from Run.host's readings; the width is COLUMNS, else the TTY columns, else 80.

def act_code source · line 8139 · raw

@fits:Bool -> @n:U32 -> Pair(U32, String)

def act_exit source · line 8147 · raw

@+n:U32 -> Pair(U32, String)

§7.2: act's code, or 70 with a stderr line when it exceeds 255.

def owed_end source · line 8157 · raw

@newline:Bool -> String

def owed_after source · line 8162 · raw

@t:String -> @c:Char -> String

def owed source · line 8168 · raw

@s:String -> String

"\n" unless s is empty or ends with one: what IO.print_err adds to s.

def ran_exit source · line 8173 · raw

@e:Pair(U32, String) -> @out:String -> @+err:String -> Ran

def ran_act source · line 8179 · raw

@r:Ran -> Ran

r with act_exit's mapping: a code above 255 becomes 70, with the bug line after r's stderr.

def utf8_lead source · line 8207 · raw

@+b:U32 -> Utf8Lead

def utf8_next source · line 8215 · raw

@ok:Bool -> @found:Maybe<&2, U32> -> Maybe<&2, U32>

def utf8_cont source · line 8222 · raw

@rest:List<&2, U32> -> @acc:U32 -> Maybe<&2, U32>

The code point acc continues to through 1, 2, or 3 continuation bytes (80..BF) of rest; None if rest ends first or one is not.

def utf8_cont2 source · line 8229 · raw

@rest:List<&2, U32> -> @acc:U32 -> Maybe<&2, U32>

def utf8_cont3 source · line 8236 · raw

@rest:List<&2, U32> -> @acc:U32 -> Maybe<&2, U32>

def utf8_tail source · line 8243 · raw

@more:Nat -> @rest:List<&2, U32> -> @acc:U32 -> Maybe<&2, U32>

def utf8_scalar source · line 8251 · raw

@found:Maybe<&2, U32> -> @least:U32 -> Maybe<&2, U32>

A decoded code point, if it is a Unicode scalar at least least.

def byte_escape source · line 8260 · raw

@+b:U32 -> Char

U+DC00 plus byte b, PEP 383's escape for a byte that starts no well-formed UTF-8 sequence; U+FFFD for a value past 255, no byte.

def arg_found source · line 8268 · raw

@found:Maybe<&2, U32> -> @more:Nat -> @b:U32 -> ArgChar

def arg_seq source · line 8273 · raw

@lead:Utf8Lead -> @b:U32 -> @rest:List<&2, U32> -> ArgChar

def arg_char_by source · line 8279 · raw

@ascii:Bool -> @+b:U32 -> @rest:List<&2, U32> -> ArgChar

def arg_char source · line 8285 · raw

@+b:U32 -> @rest:List<&2, U32> -> ArgChar

The char that byte b and the bytes after it, rest, start.

def arg_text_go source · line 8289 · raw

@bytes:List<&2, U32> -> @step:ArgChar -> String

step's char, then bytes as text once step's other bytes are skipped.

def arg_text source · line 8299 · raw

@bytes:List<&2, U32> -> String

A raw argument as text: each well-formed UTF-8 sequence as its char, and each byte that starts none as U+DC00 plus the byte (PEP 383), decoding on from the next byte. Run.main reads argv through it.

def cont_byte source · line 8304 · raw

@x:U32 -> U32

def utf8_bytes source · line 8308 · raw

@two:Bool -> @three:Bool -> @+x:U32 -> List<&2, U32>

Scalar x's UTF-8, for x from 80: 2 bytes below 800, 3 below 10000, else 4.

def code_bytes source · line 8317 · raw

@ascii:Bool -> @escape:Bool -> @scalar:Bool -> @+x:U32 -> List<&2, U32>

def char_bytes source · line 8329 · raw

@c:Char -> List<&2, U32>

The bytes c stands for: an escape's byte for U+DC80..U+DCFF, a Unicode scalar's UTF-8, and U+FFFD's for any other surrogate or a value past U+10FFFF, as Bend's writer prints them.

def arg_bytes source · line 8338 · raw

@s:String -> List<&2, U32>

The raw argument arg_text decoded to s: open a file by it with File.open_bytes.

Templates

template usage_kind source · line 1757 · raw

@-f:(@_:UsageKind -> Bool) -> @parsed:Usage -> Bool

template read_check source · line 4727 · raw

@-T:Data -> @-get:(@_:Field -> T) -> @verdict:Maybe<&2, String> -> @fields:List<&2, Field> -> @id:String -> Dec(T)

Validation first; reading a validated value never fails (§6.5).

template read_with source · line 4733 · raw

@-T:Data -> @-get:(@_:Field -> T) -> @want:Want -> @m:Matches -> @+id:String -> Dec(T)

template get_one source · line 4739 · raw

@-T:Data -> @-conv:(@_:String -> T) -> @f:Field -> T

template get_opt source · line 4744 · raw

@-T:Data -> @-conv:(@_:String -> T) -> @f:Field -> Maybe<&2, T>

template convert_all source · line 4749 · raw

@-T:Data -> @-conv:(@_:String -> T) -> @values:List<&2, String> -> List<&2, T>

template get_many source · line 4755 · raw

@-T:Data -> @-conv:(@_:String -> T) -> @f:Field -> List<&2, T>

template sample_msgs source · line 5225 · raw

@-A:Type -> @-decode:(@+m:Matches -> Dec(A)) -> @samples:List<&2, Matches> -> List<&2, String>

template sample_bugs source · line 5250 · raw

@-A:Type -> @-decode:(@+m:Matches -> Dec(A)) -> @paths:List<&2, List<&2, String>> -> @+c:Cmd -> List<&2, Problem>

Each Bug the decoder raises on a path's samples, once per path.

template check source · line 5260 · raw

@-A:Type -> @-decode:(@+m:Matches -> Dec(A)) -> @+c:Cmd -> List<&2, Problem>

template bash_arms source · line 6882 · raw

@-f:(@_:Stop -> List<&2, String>) -> @stops:List<&2, Stop> -> List<&2, String>

template eval source · line 8063 · raw

@-A:Type -> @-decode:(@+m:Matches -> Dec(A)) -> @c:Cmd -> @h:Host -> @argv:List<&2, String> -> Step<A>

The whole CLI as a function. It must stay a direct forwarding definition: P10 and P11 are proved of eval_with.

template eval_linted source · line 8075 · raw

@-A:Type -> @-decode:(@+m:Matches -> Dec(A)) -> @l:Linted -> @h:Host -> @argv:List<&2, String> -> Step<A>

eval on a Linted, without linting its spec again. It must stay a direct forwarding definition: P16, p10_linted and p11_linted are proved of eval_linted_with.

template ran_step source · line 8183 · raw

@-A:Type -> @-plan:(@+t:Term -> @_:A -> Ran) -> @s:Step<A> -> Ran

template invoke source · line 8192 · raw

@-A:Type -> @-decode:(@+m:Matches -> Dec(A)) -> @-plan:(@+t:Term -> @_:A -> Ran) -> @c:Cmd -> @h:Host -> @argv:List<&2, String> -> Ran

§7.2: what Run.planned writes and exits with, given the host and argv: Quit's code and text, or plan's run on the value and terminal, mapped by ran_act. plan builds its output whole, so an action that streams or does other IO is an act for Run.main instead.