def zsh_arms

cli@0.2.0.0 · cli.bend:6970

import cli@0.2.0.0/cli.bend as Cli
import Base

6970# The arms at ind for the visible subcommands in items, which inherit
6971# globals; their bodies are 2 deeper.
6972def zsh_arms(items: List<&2, Item>, +globals: List<&2, Item>,
6973    +lists: List<&2, List<&2, String>>, +name: String,
6974    +words: List<&2, String>, +ind: String) -> List<&2, String>:
6975  match items:
6976    case Nil{}: Nil{}
6977    case Sub{+sub, about, +children} <> tail:
6978      +here = List.append(&2, String, words, [sub])
6979      List.append(&2, String,
6980        Bool.pick(List<&2, String>, has_hidden(children), [],
6981          String.concat([ind, bar_names(sub <> find_aliases(children)), ")"]) <>
6982            last_with(zsh_cmd(children, globals, lists, name, here,
6983              zsh_arms(children, List.append(&2, Item, globals,
6984                global_items(children)), lists, name, here,
6985                String.append(ind, "          ")),
6986              String.append(ind, "  ")), " ;;")),
6987        zsh_arms(tail, globals, lists, name, words, ind))
6988    case head <> tail: zsh_arms(tail, globals, lists, name, words, ind)

Uses (13)

Used by (1)