Cli.bash_script: def of cli@0.2.0.0 Import: import cli@0.2.0.0/cli.bend as Cli Lines 6713-6740 of cli@0.2.0.0/cli.bend: https://jend.leeeet.dev/read.txt?path=cli@0.2.0.0/cli.bend&start_line=6713&end_line=6740 import Base def bash_script(+name: String, +items: List<&2, Item>) -> String: +all = all_places(items) +found = stops(all, 0n, place_lists(all, [])) +id = String.append("_", ident(name)) text_lines(List.concat(&2, String, [ ["# bash completion; needs bash 4 or later.", "", "# Sets the tables of command path $path: opts, the options to offer; subs and", "# dests, each subcommand name and the path it enters; many, the slot of the", "# variadic positional, or 0; rest, 1 when that slot is rest().", String.append(id, "_scope() {"), " opts=() subs=() dests=() many=0 rest=0", " case $path in"], bash_arms(~bash_scope_arm, found), [" esac", "}", "", "# Sets kind to what the option or positional $1 (a name, or a 1-based slot)", "# takes at $path: w, a word from values; f, a file; d, a directory; s, other", "# text. kind is empty for an option that takes no value and for a positional", "# that completes nothing; opt is 1 when the value can only follow \"=\".", String.append(id, "_arg() {"), " kind= opt=0 values=()", " case $path in"], bash_arms(~bash_arg_arm, found), [" esac", "}"], bash_engine(id, Sh.quote(name)), ])) Uses (15): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List 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=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=all_places https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=bash_arg_arm https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=bash_arms https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=bash_engine https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=bash_scope_arm https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=ident https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=place_lists https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=stops https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=text_lines