~/bend-docscommunity

zhao.bend checks

raw source on the hub · import 0x64a14ed3ebe66ae2700afc3c3bafd113/zhao.bend as Zhao

MIT License

Copyright (c) 2026 Lucas Coutinho

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

2 imports
import Base
import ./text.bend as Text

Types

type Value source · line 26 · raw

Data

type Binding source · line 31 · raw

Data

type OptionKind source · line 34 · raw

Data

type Option source · line 40 · raw

Data

type Argument source · line 43 · raw

Data

type Command source · line 46 · raw

Data

type Invocation source · line 49 · raw

Data

type Outcome source · line 52 · raw

Data

type OptionNames source · line 58 · raw

Data

type ArgumentState source · line 61 · raw

Data

type Scan source · line 64 · raw

Data

Definitions

def command.valid source · line 69 · raw

@name:String -> @valid:Bool -> Command

def command source · line 76 · raw

@+name:String -> Command

def description source · line 79 · raw

@cmd:Command -> @text:String -> Command

def version source · line 83 · raw

@cmd:Command -> @text:String -> Command

def alias source · line 87 · raw

@cmd:Command -> @text:String -> Command

def problem.first source · line 91 · raw

@first:Maybe<&2, String> -> @second:Maybe<&2, String> -> Maybe<&2, String>

def command.problem source · line 98 · raw

@cmd:Command -> @message:String -> Command

def option.names.two source · line 102 · raw

@first:String -> @second:String -> @flag:Bool -> Result<&2, &2, String, OptionNames>

def option.names source · line 109 · raw

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

def option.short_valid source · line 120 · raw

@text:String -> Bool

def option.long_valid source · line 129 · raw

@+text:String -> Bool

def option.kind.negated source · line 132 · raw

@empty:Bool -> Result<&2, &2, String, OptionKind>

def option.kind.brackets source · line 139 · raw

@name:String -> @required:Bool -> @optional:Bool -> Result<&2, &2, String, OptionKind>

def option.kind.wrapped source · line 148 · raw

@+value:String -> @valid:Bool -> Result<&2, &2, String, OptionKind>

def option.kind.value source · line 155 · raw

@+value:String -> @empty:Bool -> Result<&2, &2, String, OptionKind>

def option.kind source · line 162 · raw

@+value:String -> @negative:Bool -> Result<&2, &2, String, OptionKind>

def option.key.prefix source · line 169 · raw

@negative:Bool -> Nat

def option.key source · line 176 · raw

@+long:String -> String

def option.make.valid source · line 179 · raw

@flags:String -> @short:String -> @+long:String -> @desc:String -> @kind:OptionKind -> @fallback:Maybe<&2, Value> -> @mandatory:Bool -> @valid:Bool -> Result<&2, &2, String, Option>

def option.make.names source · line 186 · raw

@names:OptionNames -> @flags:String -> @desc:String -> @fallback:Maybe<&2, Value> -> @mandatory:Bool -> Result<&2, &2, String, Option>

def option.make source · line 190 · raw

@+flags:String -> @desc:String -> @fallback:Maybe<&2, Value> -> @mandatory:Bool -> Result<&2, &2, String, Option>

def option.clashes source · line 193 · raw

@+left:Option -> @+right:Option -> Bool

def option.conflicts source · line 198 · raw

@options:List<&2, Option> -> @+added:Option -> Bool

def option.reserved source · line 205 · raw

@opt:Option -> Bool

def option.add.valid source · line 209 · raw

@cmd:Command -> @opt:Option -> @valid:Bool -> Command

def option.add source · line 216 · raw

@cmd:Command -> @result:Result<&2, &2, String, Option> -> Command

def option source · line 223 · raw

@cmd:Command -> @flags:String -> @desc:String -> Command

def option.default.valid source · line 226 · raw

@result:Result<&2, &2, String, Option> -> Result<&2, &2, String, Option>

def option_default source · line 235 · raw

@cmd:Command -> @flags:String -> @desc:String -> @value:String -> Command

def required_option source · line 238 · raw

@cmd:Command -> @flags:String -> @desc:String -> Command

def argument.make.valid source · line 241 · raw

@syntax:String -> @name:String -> @desc:String -> @required:Bool -> @variadic:Bool -> @fallback:Maybe<&2, String> -> @valid:Bool -> Result<&2, &2, String, Argument>

def argument.make source · line 248 · raw

@+syntax:String -> @desc:String -> @fallback:Maybe<&2, String> -> Result<&2, &2, String, Argument>

def argument.conflicts source · line 256 · raw

@args:List<&2, Argument> -> @+added:Argument -> Bool

def argument.add.valid source · line 264 · raw

@cmd:Command -> @spec:Argument -> @valid:Bool -> Command

def argument.add source · line 271 · raw

@cmd:Command -> @result:Result<&2, &2, String, Argument> -> Command

def argument source · line 278 · raw

@cmd:Command -> @syntax:String -> @desc:String -> Command

def argument_default source · line 281 · raw

@cmd:Command -> @syntax:String -> @desc:String -> @value:String -> Command

def command.matches source · line 284 · raw

@cmd:Command -> @+token:String -> Bool

def command.find.hit source · line 288 · raw

@hit:Bool -> @cmd:Command -> @rest:Maybe<&2, Command> -> Maybe<&2, Command>

def command.find source · line 295 · raw

@commands:List<&2, Command> -> @+token:String -> Maybe<&2, Command>

def command.conflicts source · line 302 · raw

@commands:List<&2, Command> -> @+name:String -> @+alt:String -> Bool

def subcommand.valid source · line 309 · raw

@cmd:Command -> @child:Command -> @valid:Bool -> Command

def subcommand source · line 316 · raw

@cmd:Command -> @+child:Command -> Command

def bindings.get.hit source · line 322 · raw

@hit:Bool -> @value:Value -> @rest:Maybe<&2, Value> -> Maybe<&2, Value>

def bindings.get source · line 329 · raw

@bindings:List<&2, Binding> -> @+key:String -> Maybe<&2, Value>

def get source · line 336 · raw

@invocation:Invocation -> @key:String -> Maybe<&2, Value>

def arg source · line 340 · raw

@invocation:Invocation -> @key:String -> Maybe<&2, Value>

def value.text source · line 344 · raw

@value:Maybe<&2, Value> -> @fallback:String -> String

def value.enabled source · line 351 · raw

@value:Maybe<&2, Value> -> Bool

def value.many source · line 358 · raw

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

def path source · line 365 · raw

@invocation:Invocation -> List<&2, String>

def value.show source · line 369 · raw

@value:Value -> String

def help.default source · line 378 · raw

@value:Maybe<&2, Value> -> String

def help.options source · line 385 · raw

@options:List<&2, Option> -> String

def help.argument_default source · line 392 · raw

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

def help.arguments source · line 399 · raw

@args:List<&2, Argument> -> String

def help.usage source · line 406 · raw

@args:List<&2, Argument> -> String

def help.commands source · line 413 · raw

@commands:List<&2, Command> -> String

def help.section source · line 420 · raw

@title:String -> @+body:String -> String

def help.render source · line 423 · raw

@cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> String

def help source · line 433 · raw

@+cmd:Command -> String

def bindings.remove.keep source · line 437 · raw

@remove:Bool -> @binding:Binding -> @rest:List<&2, Binding> -> List<&2, Binding>

def bindings.remove source · line 444 · raw

@bindings:List<&2, Binding> -> @+key:String -> List<&2, Binding>

def bindings.set source · line 452 · raw

@bindings:List<&2, Binding> -> @+key:String -> @value:Value -> List<&2, Binding>

def option.find.hit source · line 455 · raw

@hit:Bool -> @opt:Option -> @rest:Maybe<&2, Option> -> Maybe<&2, Option>

def option.find source · line 462 · raw

@options:List<&2, Option> -> @+flag:String -> Maybe<&2, Option>

def options.clash source · line 470 · raw

@added:List<&2, Option> -> @+existing:List<&2, Option> -> Bool

def option.fallback source · line 477 · raw

@kind:OptionKind -> @fallback:Maybe<&2, Value> -> Maybe<&2, Value>

def options.finish.value source · line 486 · raw

@values:List<&2, Binding> -> @key:String -> @current:Maybe<&2, Value> -> @fallback:Maybe<&2, Value> -> @mandatory:Bool -> @flags:String -> Result<&2, &2, Outcome, List<&2, Binding>>

def options.finish source · line 497 · raw

@options:List<&2, Option> -> @result:Result<&2, &2, Outcome, List<&2, Binding>> -> Result<&2, &2, Outcome, List<&2, Binding>>

def argument.empty source · line 506 · raw

@values:List<&2, Binding> -> @key:String -> @required:Bool -> @variadic:Bool -> @fallback:Maybe<&2, String> -> Result<&2, &2, Outcome, ArgumentState>

def argument.consume source · line 519 · raw

@spec:Argument -> @words:List<&2, String> -> @values:List<&2, Binding> -> Result<&2, &2, Outcome, ArgumentState>

def arguments.loop source · line 528 · raw

@args:List<&2, Argument> -> @state:Result<&2, &2, Outcome, ArgumentState> -> Result<&2, &2, Outcome, List<&2, Binding>>

def arguments.finish source · line 539 · raw

@args:List<&2, Argument> -> @words:List<&2, String> -> Result<&2, &2, Outcome, List<&2, Binding>>

def parse.complete.results source · line 542 · raw

@options:Result<&2, &2, Outcome, List<&2, Binding>> -> @args:Result<&2, &2, Outcome, List<&2, Binding>> -> @names:List<&2, String> -> Outcome

def parse.complete.commands source · line 551 · raw

@commands:List<&2, Command> -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @args:List<&2, Argument> -> @words:List<&2, String> -> Outcome

def parse.complete source · line 559 · raw

@cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> Outcome

def parse.select.valid source · line 563 · raw

@cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @remaining:List<&2, String> -> @clash:Bool -> Scan

def parse.select source · line 570 · raw

@+child:Command -> @names:List<&2, String> -> @+options:List<&2, Option> -> @values:List<&2, Binding> -> @remaining:List<&2, String> -> Scan

def parse.word.child source · line 574 · raw

@found:Maybe<&2, Command> -> @children:List<&2, Command> -> @cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @word:String -> @remaining:List<&2, String> -> Scan

def parse.word source · line 583 · raw

@+cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @+word:String -> @remaining:List<&2, String> -> Scan

def parse.required source · line 587 · raw

@remaining:List<&2, String> -> @cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @key:String -> @token:String -> Scan

def parse.optional.value source · line 594 · raw

@cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @key:String -> @text:String -> @tail:List<&2, String> -> @consume:Bool -> Scan

def parse.optional source · line 601 · raw

@remaining:List<&2, String> -> @cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @key:String -> Scan

def parse.builtin.kind source · line 608 · raw

@cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @token:String -> @ver:String -> @is_help:Bool -> @is_version:Bool -> Scan

def parse.builtin source · line 617 · raw

@+cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @+token:String -> Scan

def parse.option source · line 621 · raw

@found:Maybe<&2, Option> -> @attached:Maybe<&2, String> -> @cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @token:String -> @remaining:List<&2, String> -> Scan

def parse.flag.long source · line 640 · raw

@split:Pair(String, Maybe<&2, String>) -> @cmd:Command -> @names:List<&2, String> -> @+options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @token:String -> @remaining:List<&2, String> -> Scan

def parse.cluster source · line 644 · raw

@suffix:String -> @remaining:List<&2, String> -> List<&2, String>

def parse.attached source · line 651 · raw

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

def parse.flag.short.kind source · line 658 · raw

@kind:OptionKind -> @opt:Option -> @cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @flag:String -> @suffix:String -> @remaining:List<&2, String> -> Scan

def parse.flag.short source · line 667 · raw

@found:Maybe<&2, Option> -> @cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @flag:String -> @suffix:String -> @remaining:List<&2, String> -> Scan

def parse.flag.form source · line 675 · raw

@long:Bool -> @cmd:Command -> @names:List<&2, String> -> @+options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @+token:String -> @remaining:List<&2, String> -> Scan

def parse.flag source · line 684 · raw

@cmd:Command -> @names:List<&2, String> -> @+options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @+token:String -> @remaining:List<&2, String> -> Scan

def parse.token.kind source · line 687 · raw

@cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @token:String -> @remaining:List<&2, String> -> @delimiter:Bool -> @flag:Bool -> @help_command:Bool -> Scan

def parse.token source · line 698 · raw

@+cmd:Command -> @names:List<&2, String> -> @options:List<&2, Option> -> @values:List<&2, Binding> -> @words:List<&2, String> -> @+token:String -> @remaining:List<&2, String> -> Scan

def parse.help.select source · line 702 · raw

@state:Scan -> Scan

def parse.help.child source · line 709 · raw

@found:Maybe<&2, Command> -> @names:List<&2, String> -> @options:List<&2, Option> -> @token:String -> @remaining:List<&2, String> -> Scan

def parse.step source · line 716 · raw

@state:Scan -> Scan

def parse.scan source · line 731 · raw

@fuel:Nat -> @state:Scan -> Outcome

def parse.start source · line 740 · raw

@+cmd:Command -> @+argv:List<&2, String> -> @problem:Maybe<&2, String> -> Outcome

def parse source · line 747 · raw

@+cmd:Command -> @argv:List<&2, String> -> Outcome

def dispatch source · line 751 · raw

@outcome:Outcome -> @action:(@_:Invocation -> IO(Unit)) -> IO(Unit)

def run source · line 762 · raw

@cmd:Command -> @action:(@_:Invocation -> IO(Unit)) -> IO(Unit)