The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

zsh completion: fix completion of files and dirs on glued forms

Close #230

+41 -13
+6 -4
vendor/opam/cmdliner/B0.ml
··· 64 64 let bash = B0_env.in_scope_dir env ~/"src/tool/bash-completion.sh" in 65 65 let zsh = B0_env.in_scope_dir env ~/"src/tool/zsh-completion.sh" in 66 66 let pwsh = B0_env.in_scope_dir env ~/"src/tool/pwsh-completion.ps1" in 67 + let munge_src src = 68 + src 69 + |> String.replace_all ~sub:"%" ~by:"%%" (* need to escape for fmt *) 70 + |> String.replace_first ~sub:"_cmdliner_generic" ~by:"%s" 71 + in 67 72 let ml = B0_env.in_scope_dir env ~/"src/tool/cmdliner_data.ml" in 68 73 let* bash = Os.File.read bash in 69 - let bash = String.replace_first ~sub:"_cmdliner_generic" ~by:"%s" bash in 70 74 let* zsh = Os.File.read zsh in 71 - let zsh = String.replace_first ~sub:"_cmdliner_generic" ~by:"%s" zsh in 72 75 let* pwsh = Os.File.read pwsh in 73 - let pwsh = String.replace_first ~sub:"_cmdliner_generic" ~by:"%s" pwsh in 74 76 let src = Fmt.str 75 77 "let strf = Printf.sprintf\n\n\ 76 78 let bash_generic_completion fun_name = strf\n{|%s\ ··· 78 80 let zsh_generic_completion fun_name = strf\n{|%s\ 79 81 |} fun_name\n\n\ 80 82 let pwsh_generic_completion fun_name = strf\n{|%s\ 81 - |} fun_name" bash zsh pwsh 83 + |} fun_name" (munge_src bash) (munge_src zsh) (munge_src pwsh) 82 84 in 83 85 Os.File.write ~force:true ~make_path:false ml src 84 86
+4
vendor/opam/cmdliner/CHANGES.md
··· 11 11 - zsh completion: strip ANSI escapes from doc strings. The experience 12 12 is too unreliable (#220). 13 13 14 + - zsh completion: fix completion of files and directories on glued 15 + forms (#230). 16 + Thanks to Brian Ward for the help. 17 + 14 18 - cmdliner tool: add support for generating standalone completion 15 19 scripts via the `--standalone-completion`. Can be used if your 16 20 users don't have the cmdliner library installed (#243).
+15 -4
vendor/opam/cmdliner/src/tool/cmdliner_data.ml
··· 134 134 fi 135 135 item_doc="${item_doc//$'\e'\[(01m|04m|m)/}" 136 136 completions+=("${item}":"${item_doc}") 137 - elif [[ "$type" == "dirs" ]]; then 138 - _path_files -/ 139 - elif [[ "$type" == "files" ]]; then 140 - _path_files -f 137 + elif [[ "$type" == "dirs" || "$type" == "files" ]]; then 138 + local pre="" 139 + local pat="$prefix" 140 + if [[ "$prefix" == --* ]]; then 141 + pre="${prefix%%=*}=" 142 + pat="${prefix#*=}" 143 + elif [[ "$prefix" == -* ]]; then 144 + pre="${prefix:0:2}" 145 + pat="${prefix:2}" 146 + fi 147 + if [[ "$type" == "dirs" ]]; then 148 + _path_files -/ -P "$pre" "$pat" 149 + else 150 + _path_files -f -P "$pre" "$pat" 151 + fi 141 152 elif [[ "$type" == "restart" ]]; then 142 153 # N.B. only emitted if there is a -- token 143 154 while [[ $words[1] != "--" ]]; do
+16 -5
vendor/opam/cmdliner/src/tool/zsh-completion.sh
··· 43 43 # Handle glued forms, the completion item is the full option 44 44 if [[ "$group" == "Values" ]]; then 45 45 if [[ "$prefix" == --* ]]; then 46 - item="${prefix%%=*}=${item}" 46 + item="${prefix%=*}=${item}" 47 47 elif [[ "$prefix" == -* ]]; then 48 48 item="${prefix:0:2}${item}" 49 49 fi 50 50 fi 51 51 item_doc="${item_doc//$'\e'\[(01m|04m|m)/}" 52 52 completions+=("${item}":"${item_doc}") 53 - elif [[ "$type" == "dirs" ]]; then 54 - _path_files -/ 55 - elif [[ "$type" == "files" ]]; then 56 - _path_files -f 53 + elif [[ "$type" == "dirs" || "$type" == "files" ]]; then 54 + local pre="" 55 + local pat="$prefix" 56 + if [[ "$prefix" == --* ]]; then 57 + pre="${prefix%=*}=" 58 + pat="${prefix#*=}" 59 + elif [[ "$prefix" == -* ]]; then 60 + pre="${prefix:0:2}" 61 + pat="${prefix:2}" 62 + fi 63 + if [[ "$type" == "dirs" ]]; then 64 + _path_files -/ -P "$pre" "$pat" 65 + else 66 + _path_files -f -P "$pre" "$pat" 67 + fi 57 68 elif [[ "$type" == "restart" ]]; then 58 69 # N.B. only emitted if there is a -- token 59 70 while [[ $words[1] != "--" ]]; do