Cli.fish_script: def of cli@0.2.0.0 Import: import cli@0.2.0.0/cli.bend as Cli Lines 7294-7329 of cli@0.2.0.0/cli.bend: https://jend.leeeet.dev/read.txt?path=cli@0.2.0.0/cli.bend&start_line=7294&end_line=7329 import Base def fish_script(+name: String, +items: List<&2, Item>) -> String: +all = all_places(items) +lists = place_lists(all, []) +found = stops(all, 0n, lists) +id = String.append("__", ident(name)) +cq = Fish.quote(name) text_lines(List.concat(&2, String, [ ["# fish completion; needs fish 3.3 or later.", "", "# Prints the number of the path that subcommand $argv[2] of path $argv[1]", "# enters; paths are numbered in pre-order from 0, the root.", String.concat(["function ", id, "_dest"]), " switch \"$argv[1] $argv[2]\""], fish_dests(found, found), [" case '*'", " return 1", " end", "end", "", "# Succeeds when option $argv[2] takes the next word as its value at path", "# $argv[1].", String.concat(["function ", id, "_valued"]), " switch $argv[1]"], bash_arms(~fish_valued, found), [" case '*'", " return 1", " end", "end", "", "# Prints how path $argv[1] takes words: 1 if it has subcommands, else 0; the", "# slot of its variadic positional, or 0; 1 if that slot is rest(), else 0.", String.concat(["function ", id, "_shape"]), " switch $argv[1]"], bash_arms(~fish_shape, found), [" case '*'", " echo 0 0 0", " end", "end"], fish_values_fn(id, lists), fish_engine(id), ["", "# Option lines also hold at v, so that fish can read grouped short options", "# before a value, as in -vC DIR.", String.concat(["complete -c ", cq, " -f"])], fish_lines(found, String.concat(["complete -c ", cq, " -n '", id, "_is "]), id), ])) Uses (19): 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=Base/base.bend&name=String.concat https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=Fish.quote 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=all_places 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=fish_dests https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=fish_engine https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=fish_lines https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=fish_shape https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=fish_valued https://jend.leeeet.dev/definition.txt?path=cli@0.2.0.0/cli.bend&name=fish_values_fn 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