~/bend-docscommunity

zhao.bend checks

raw source on the hub · import 0x014d1ec5074b05cc46cbfd40d4033fe1/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 41 · raw

Data

type Argument source · line 44 · raw

Data

type Command source · line 47 · raw

Data

type Invocation source · line 50 · raw

Data

type Outcome source · line 53 · raw

Data

type OptionNames source · line 59 · raw

Data

type ArgumentState source · line 62 · raw

Data

type Scan source · line 65 · raw

Data

Definitions

def command.valid source · line 70 · raw

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

def command source · line 77 · raw

@+name:String -> Command

def description source · line 80 · raw

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

def version source · line 84 · raw

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

def alias source · line 88 · raw

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

def problem.first source · line 92 · raw

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

def command.problem source · line 99 · raw

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

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

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

def option.names source · line 110 · raw

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

def option.short_valid source · line 121 · raw

@text:String -> Bool

def option.long_valid source · line 130 · raw

@+text:String -> Bool

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

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

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

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

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

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

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

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

def option.kind source · line 163 · raw

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

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

@negative:Bool -> Nat

def option.key source · line 177 · raw

@+long:String -> String

def option.make.valid source · line 180 · 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 187 · raw

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

def option.make source · line 191 · raw

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

def option.clashes source · line 194 · raw

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

def option.conflicts source · line 199 · raw

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

def option.reserved source · line 206 · raw

@opt:Option -> Bool

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

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

def option.add source · line 217 · raw

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

def option source · line 224 · raw

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

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

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

def option_default source · line 236 · raw

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

def required_option source · line 239 · raw

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

def option.repeatable source · line 242 · raw

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

def repeatable_option source · line 251 · raw

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

def argument.make.valid source · line 254 · 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 261 · raw

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

def argument.conflicts source · line 269 · raw

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

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

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

def argument.add source · line 284 · raw

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

def argument source · line 291 · raw

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

def argument_default source · line 294 · raw

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

def command.matches source · line 297 · raw

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

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

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

def command.find source · line 308 · raw

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

def command.conflicts source · line 315 · raw

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

def subcommand.valid source · line 322 · raw

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

def subcommand source · line 329 · raw

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

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

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

def bindings.get source · line 342 · raw

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

def get source · line 349 · raw

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

def arg source · line 353 · raw

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

def value.text source · line 357 · raw

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

def value.enabled source · line 364 · raw

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

def value.many source · line 371 · raw

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

def path source · line 378 · raw

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

def value.show source · line 382 · raw

@value:Value -> String

def help.default source · line 391 · raw

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

def help.options source · line 398 · raw

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

def help.argument_default source · line 405 · raw

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

def help.arguments source · line 412 · raw

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

def help.usage source · line 419 · raw

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

def help.commands source · line 426 · raw

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

def help.section source · line 433 · raw

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

def help.render source · line 436 · raw

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

def help source · line 446 · raw

@+cmd:Command -> String

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

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

def bindings.remove source · line 457 · raw

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

def bindings.set source · line 465 · raw

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

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

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

def option.find source · line 475 · raw

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

def options.clash source · line 483 · raw

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

def option.fallback source · line 490 · raw

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

def options.finish.value source · line 501 · 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 512 · 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 521 · 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 534 · raw

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

def arguments.loop source · line 543 · raw

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

def arguments.finish source · line 554 · raw

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

def parse.complete.results source · line 557 · 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 566 · 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 574 · 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 578 · 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 585 · 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 589 · 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 598 · 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 option.store source · line 602 · raw

@kind:OptionKind -> @+values:List<&2, Binding> -> @+key:String -> @text:String -> List<&2, Binding>

def parse.required source · line 610 · 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 -> @kind:OptionKind -> Scan

def parse.optional.value source · line 617 · 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 624 · 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 631 · 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 640 · raw

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

def parse.option source · line 644 · 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 663 · 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 667 · raw

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

def parse.attached source · line 674 · raw

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

def parse.flag.short.kind source · line 681 · 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 690 · 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 698 · 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 707 · 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 710 · 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 721 · 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 725 · raw

@state:Scan -> Scan

def parse.help.child source · line 732 · 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 739 · raw

@state:Scan -> Scan

def parse.scan source · line 754 · raw

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

def parse.start source · line 763 · raw

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

def parse source · line 770 · raw

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

def dispatch source · line 774 · raw

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

def run source · line 785 · raw

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