Cli.zsh_branch: def of cli@0.2.0.0 Import: import cli@0.2.0.0/cli.bend as Cli Lines 6910-6943 of cli@0.2.0.0/cli.bend: https://jend.leeeet.dev/read.txt?path=cli@0.2.0.0/cli.bend&start_line=6910&end_line=6943 import Base # 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_branch(+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>: +state = String.join(name <> words, "-") +i2 = String.append(ind, " ") +hstate = String.append(state, "-help") +label = zsh_label(name, words) List.concat(&2, String, [ zsh_ends(words, ind), last_with(zsh_args(ind, List.append(&2, String, specs, [String.append("*:: :->", state)])), " && return"), [String.append(ind, "case $state in"), String.concat([ind, " ", Sh.quote(state), ")"]), zsh_past_end(i2), String.append(i2, "if (( CURRENT == 1 )); then")], zsh_commands(entries, True{}, label, String.append(i2, " ")), [String.append(i2, "else"), String.append(i2, " case $words[1] in")], arms, [String.append(i2, " 'help')")], last_with(zsh_args(String.append(i2, " "), ["(-h --help)-h[Print help]", "(-h --help)--help[Print help]", String.append("*:: :->", hstate)]), " && return"), [String.append(i2, " case $state in"), String.concat([i2, " ", Sh.quote(hstate), ")"]), zsh_past_end(String.append(i2, " "))], last_with(zsh_help_tree(entries, label, zsh_help_arms(items, name, words, 1n, String.append(i2, " ")), 1n, String.append(i2, " ")), " ;;"), [String.append(i2, " esac ;;"), String.append(i2, " esac"), String.append(i2, "fi ;;"), String.append(ind, "esac")], ]) Uses (19): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.append https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.concat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.append https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.concat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.join https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=Entry https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=Item https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=Sh.quote https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=last_with https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=zsh_args https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=zsh_commands https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=zsh_ends https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=zsh_help_arms https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=zsh_help_tree https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=zsh_label https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=zsh_past_end