···6464 let bash = B0_env.in_scope_dir env ~/"src/tool/bash-completion.sh" in
6565 let zsh = B0_env.in_scope_dir env ~/"src/tool/zsh-completion.sh" in
6666 let pwsh = B0_env.in_scope_dir env ~/"src/tool/pwsh-completion.ps1" in
6767+ let munge_src src =
6868+ src
6969+ |> String.replace_all ~sub:"%" ~by:"%%" (* need to escape for fmt *)
7070+ |> String.replace_first ~sub:"_cmdliner_generic" ~by:"%s"
7171+ in
6772 let ml = B0_env.in_scope_dir env ~/"src/tool/cmdliner_data.ml" in
6873 let* bash = Os.File.read bash in
6969- let bash = String.replace_first ~sub:"_cmdliner_generic" ~by:"%s" bash in
7074 let* zsh = Os.File.read zsh in
7171- let zsh = String.replace_first ~sub:"_cmdliner_generic" ~by:"%s" zsh in
7275 let* pwsh = Os.File.read pwsh in
7373- let pwsh = String.replace_first ~sub:"_cmdliner_generic" ~by:"%s" pwsh in
7476 let src = Fmt.str
7577 "let strf = Printf.sprintf\n\n\
7678 let bash_generic_completion fun_name = strf\n{|%s\
···7880 let zsh_generic_completion fun_name = strf\n{|%s\
7981 |} fun_name\n\n\
8082 let pwsh_generic_completion fun_name = strf\n{|%s\
8181- |} fun_name" bash zsh pwsh
8383+ |} fun_name" (munge_src bash) (munge_src zsh) (munge_src pwsh)
8284 in
8385 Os.File.write ~force:true ~make_path:false ml src
8486
+4
vendor/opam/cmdliner/CHANGES.md
···1111- zsh completion: strip ANSI escapes from doc strings. The experience
1212 is too unreliable (#220).
13131414+- zsh completion: fix completion of files and directories on glued
1515+ forms (#230).
1616+ Thanks to Brian Ward for the help.
1717+1418- cmdliner tool: add support for generating standalone completion
1519 scripts via the `--standalone-completion`. Can be used if your
1620 users don't have the cmdliner library installed (#243).
+15-4
vendor/opam/cmdliner/src/tool/cmdliner_data.ml
···134134 fi
135135 item_doc="${item_doc//$'\e'\[(01m|04m|m)/}"
136136 completions+=("${item}":"${item_doc}")
137137- elif [[ "$type" == "dirs" ]]; then
138138- _path_files -/
139139- elif [[ "$type" == "files" ]]; then
140140- _path_files -f
137137+ elif [[ "$type" == "dirs" || "$type" == "files" ]]; then
138138+ local pre=""
139139+ local pat="$prefix"
140140+ if [[ "$prefix" == --* ]]; then
141141+ pre="${prefix%%=*}="
142142+ pat="${prefix#*=}"
143143+ elif [[ "$prefix" == -* ]]; then
144144+ pre="${prefix:0:2}"
145145+ pat="${prefix:2}"
146146+ fi
147147+ if [[ "$type" == "dirs" ]]; then
148148+ _path_files -/ -P "$pre" "$pat"
149149+ else
150150+ _path_files -f -P "$pre" "$pat"
151151+ fi
141152 elif [[ "$type" == "restart" ]]; then
142153 # N.B. only emitted if there is a -- token
143154 while [[ $words[1] != "--" ]]; do
+16-5
vendor/opam/cmdliner/src/tool/zsh-completion.sh
···4343 # Handle glued forms, the completion item is the full option
4444 if [[ "$group" == "Values" ]]; then
4545 if [[ "$prefix" == --* ]]; then
4646- item="${prefix%%=*}=${item}"
4646+ item="${prefix%=*}=${item}"
4747 elif [[ "$prefix" == -* ]]; then
4848 item="${prefix:0:2}${item}"
4949 fi
5050 fi
5151 item_doc="${item_doc//$'\e'\[(01m|04m|m)/}"
5252 completions+=("${item}":"${item_doc}")
5353- elif [[ "$type" == "dirs" ]]; then
5454- _path_files -/
5555- elif [[ "$type" == "files" ]]; then
5656- _path_files -f
5353+ elif [[ "$type" == "dirs" || "$type" == "files" ]]; then
5454+ local pre=""
5555+ local pat="$prefix"
5656+ if [[ "$prefix" == --* ]]; then
5757+ pre="${prefix%=*}="
5858+ pat="${prefix#*=}"
5959+ elif [[ "$prefix" == -* ]]; then
6060+ pre="${prefix:0:2}"
6161+ pat="${prefix:2}"
6262+ fi
6363+ if [[ "$type" == "dirs" ]]; then
6464+ _path_files -/ -P "$pre" "$pat"
6565+ else
6666+ _path_files -f -P "$pre" "$pat"
6767+ fi
5768 elif [[ "$type" == "restart" ]]; then
5869 # N.B. only emitted if there is a -- token
5970 while [[ $words[1] != "--" ]]; do