| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#, Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#}; |
| 2 | |
| 3 | use claprust-analyzer cargo clap 4.6.6 crate/::{Argrust-analyzer cargo clap_builder 4.6.6 builder/arg/Arg#, ArgActionrust-analyzer cargo clap_builder 4.6.6 builder/action/ArgAction#, Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#}; |
| 4 | |
| 5 | use craterust-analyzer cargo clap_complete 4.6.8 crate/::INTERNAL_ERROR_MSGrust-analyzer cargo clap_complete 4.6.8 INTERNAL_ERROR_MSG.; |
| 6 | use craterust-analyzer cargo clap_complete 4.6.8 crate/::generatorrust-analyzer cargo clap_complete 4.6.8 generator/::{Generatorrust-analyzer cargo clap_complete 4.6.8 aot/generator/Generator#, utilsrust-analyzer cargo clap_complete 4.6.8 aot/generator/utils/}; |
| 7 | |
| 8 | /// Generate zsh completion file |
| 9 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 10 | pub struct Zshrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/Zsh#; |
| 11 | |
| 12 | impl Generatorrust-analyzer cargo clap_complete 4.6.8 aot/generator/Generator# for Zshrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/Zsh# { |
| 13 | fn file_namerust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/impl#[Zsh][Generator]file_name().(&self, name: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 14 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("_{name}") |
| 15 | } |
| 16 | |
| 17 | fn generaterust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/impl#[Zsh][Generator]generate().(&self, cmd: &Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, buf: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) { |
| 18 | self.try_generaterust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/impl#[Zsh][Generator]try_generate().(cmd, buf) |
| 19 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("failed to write completion file"); |
| 20 | } |
| 21 | |
| 22 | fn try_generaterust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/impl#[Zsh][Generator]try_generate().(&self, cmd: &Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, buf: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> { |
| 23 | let bin_name = cmd |
| 24 | .get_bin_namerust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_bin_name().() |
| 25 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("crate::generate should have set the bin_name"); |
| 26 | |
| 27 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 28 | buf, |
| 29 | "#compdef {name} |
| 30 | |
| 31 | autoload -U is-at-least |
| 32 | |
| 33 | _{name}() {{ |
| 34 | typeset -A opt_args |
| 35 | typeset -a _arguments_options |
| 36 | local ret=1 |
| 37 | |
| 38 | if is-at-least 5.2; then |
| 39 | _arguments_options=(-s -S -C) |
| 40 | else |
| 41 | _arguments_options=(-s -C) |
| 42 | fi |
| 43 | |
| 44 | local context curcontext=\"$curcontext\" state line |
| 45 | {initial_args}{subcommands} |
| 46 | }} |
| 47 | |
| 48 | {subcommand_details} |
| 49 | |
| 50 | if [ \"$funcstack[1]\" = \"_{name}\" ]; then |
| 51 | _{name} \"$@\" |
| 52 | else |
| 53 | compdef _{name} {name} |
| 54 | fi |
| 55 | ", |
| 56 | name = bin_name, |
| 57 | initial_args = get_args_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/get_args_of().(cmd, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 58 | subcommands = get_subcommands_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/get_subcommands_of().(cmd), |
| 59 | subcommand_details = subcommand_detailsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/subcommand_details().(cmd) |
| 60 | ) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | // Displays the commands of a subcommand |
| 65 | // (( $+functions[_[bin_name_underscore]_commands] )) || |
| 66 | // _[bin_name_underscore]_commands() { |
| 67 | // local commands; commands=( |
| 68 | // '[arg_name]:[arg_help]' |
| 69 | // ) |
| 70 | // _describe -t commands '[bin_name] commands' commands "$@" |
| 71 | // |
| 72 | // Where the following variables are present: |
| 73 | // [bin_name_underscore]: The full space delineated bin_name, where spaces have been replaced by |
| 74 | // underscore characters |
| 75 | // [arg_name]: The name of the subcommand |
| 76 | // [arg_help]: The help message of the subcommand |
| 77 | // [bin_name]: The full space delineated bin_name |
| 78 | // |
| 79 | // Here's a snippet from rustup: |
| 80 | // |
| 81 | // (( $+functions[_rustup_commands] )) || |
| 82 | // _rustup_commands() { |
| 83 | // local commands; commands=( |
| 84 | // 'show:Show the active and installed toolchains' |
| 85 | // 'update:Update Rust toolchains' |
| 86 | // # ... snip for brevity |
| 87 | // 'help:Print this message or the help of the given subcommand(s)' |
| 88 | // ) |
| 89 | // _describe -t commands 'rustup commands' commands "$@" |
| 90 | // |
| 91 | fn subcommand_detailsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/subcommand_details().(p: &Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 92 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("subcommand_details"); |
| 93 | |
| 94 | let bin_name = p |
| 95 | .get_bin_namerust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_bin_name().() |
| 96 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("crate::generate should have set the bin_name"); |
| 97 | |
| 98 | let mut ret = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 99 | |
| 100 | // First we do ourself |
| 101 | let parent_text = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 102 | "\ |
| 103 | (( $+functions[_{bin_name_underscore}_commands] )) || |
| 104 | _{bin_name_underscore}_commands() {{ |
| 105 | local commands; commands=({subcommands_and_args}) |
| 106 | _describe -t commands '{bin_name} commands' commands \"$@\" |
| 107 | }}", |
| 108 | bin_name_underscore = bin_name.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(' ', CMD_SEPrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/CMD_SEP.), |
| 109 | bin_name = bin_name, |
| 110 | subcommands_and_args = subcommands_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/subcommands_of().(p) |
| 111 | ); |
| 112 | ret.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(parent_text); |
| 113 | |
| 114 | // Next we start looping through all the children, grandchildren, etc. |
| 115 | let mut all_subcommand_bins: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = utilsrust-analyzer cargo clap_complete 4.6.8 aot/generator/utils/::all_subcommandsrust-analyzer cargo clap_complete 4.6.8 aot/generator/utils/all_subcommands().(p) |
| 116 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 117 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(_sc_name, bin_name)| bin_name) |
| 118 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 119 | |
| 120 | all_subcommand_bins.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().(); |
| 121 | all_subcommand_bins.deduprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]dedup().(); |
| 122 | |
| 123 | for bin_name in &all_subcommand_bins { |
| 124 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("subcommand_details:iter: bin_name={bin_name}"); |
| 125 | |
| 126 | ret.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 127 | "\ |
| 128 | (( $+functions[_{bin_name_underscore}_commands] )) || |
| 129 | _{bin_name_underscore}_commands() {{ |
| 130 | local commands; commands=({subcommands_and_args}) |
| 131 | _describe -t commands '{bin_name} commands' commands \"$@\" |
| 132 | }}", |
| 133 | bin_name_underscore = bin_name.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(' ', CMD_SEPrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/CMD_SEP.), |
| 134 | bin_name = bin_name, |
| 135 | subcommands_and_args = |
| 136 | subcommands_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/subcommands_of().(parser_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/parser_of().(p, bin_name).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().(INTERNAL_ERROR_MSGrust-analyzer cargo clap_complete 4.6.8 INTERNAL_ERROR_MSG.)) |
| 137 | )); |
| 138 | } |
| 139 | |
| 140 | ret.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\n") |
| 141 | } |
| 142 | |
| 143 | // Generates subcommand completions in form of |
| 144 | // |
| 145 | // '[arg_name]:[arg_help]' |
| 146 | // |
| 147 | // Where: |
| 148 | // [arg_name]: the subcommand's name |
| 149 | // [arg_help]: the help message of the subcommand |
| 150 | // |
| 151 | // A snippet from rustup: |
| 152 | // 'show:Show the active and installed toolchains' |
| 153 | // 'update:Update Rust toolchains' |
| 154 | fn subcommands_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/subcommands_of().(p: &Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 155 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("subcommands_of"); |
| 156 | |
| 157 | let mut segments = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 158 | |
| 159 | fn add_subcommandsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/add_subcommands().(subcommand: &Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, name: &str, ret: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) { |
| 160 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("add_subcommands"); |
| 161 | |
| 162 | let text = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 163 | "'{name}:{help}' \\", |
| 164 | name = name, |
| 165 | help = escape_helprust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_help().(&subcommand.get_aboutrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_about().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 166 | ); |
| 167 | |
| 168 | ret.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(text); |
| 169 | } |
| 170 | |
| 171 | // The subcommands |
| 172 | for command in p.get_subcommandsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_subcommands().() { |
| 173 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("subcommands_of:iter: subcommand={}", command.get_name()); |
| 174 | |
| 175 | add_subcommandsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/add_subcommands().(command, command.get_namerust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_name().(), &mut segments); |
| 176 | |
| 177 | for alias in command.get_visible_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_visible_aliases().() { |
| 178 | add_subcommandsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/add_subcommands().(command, alias, &mut segments); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | // Surround the text with newlines for proper formatting. |
| 183 | // We need this to prevent weirdly formatted `command=(\n \n)` sections. |
| 184 | // When there are no (sub-)commands. |
| 185 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().segments.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 186 | segments.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]insert().(0, "".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 187 | segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(" ".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 188 | } |
| 189 | |
| 190 | segments.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\n") |
| 191 | } |
| 192 | |
| 193 | // Gets the subcommand section of a completion file |
| 194 | // This looks roughly like: |
| 195 | // |
| 196 | // case $state in |
| 197 | // ([bin_name]_args) |
| 198 | // curcontext=\"${curcontext%:*:*}:[name_hyphen]-command-$words[1]:\" |
| 199 | // case $line[1] in |
| 200 | // |
| 201 | // ([name]) |
| 202 | // _arguments -C -s -S \ |
| 203 | // [subcommand_args] |
| 204 | // && ret=0 |
| 205 | // |
| 206 | // [RECURSIVE_CALLS] |
| 207 | // |
| 208 | // ;;", |
| 209 | // |
| 210 | // [repeat] |
| 211 | // |
| 212 | // esac |
| 213 | // ;; |
| 214 | // esac", |
| 215 | // |
| 216 | // Where the following variables are present: |
| 217 | // [name] = The subcommand name in the form of "install" for "rustup toolchain install" |
| 218 | // [bin_name] = The full space delineated bin_name such as "rustup toolchain install" |
| 219 | // [name_hyphen] = The full space delineated bin_name, but replace spaces with hyphens |
| 220 | // [repeat] = From the same recursive calls, but for all subcommands |
| 221 | // [subcommand_args] = The same as zsh::get_args_of |
| 222 | fn get_subcommands_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/get_subcommands_of().(parent: &Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 223 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!( |
| 224 | "get_subcommands_of: Has subcommands...{:?}", |
| 225 | parent.has_subcommands() |
| 226 | ); |
| 227 | |
| 228 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parent.has_subcommandsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]has_subcommands().() { |
| 229 | return Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 230 | } |
| 231 | |
| 232 | let subcommand_names = utilsrust-analyzer cargo clap_complete 4.6.8 aot/generator/utils/::subcommandsrust-analyzer cargo clap_complete 4.6.8 aot/generator/utils/subcommands().(parent); |
| 233 | let mut all_subcommands = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 234 | |
| 235 | for (name, bin_name) in &subcommand_names { |
| 236 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!( |
| 237 | "get_subcommands_of:iter: parent={}, name={name}, bin_name={bin_name}", |
| 238 | parent.get_name(), |
| 239 | ); |
| 240 | let mut segments = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("({name})")]; |
| 241 | let subcommand_args = get_args_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/get_args_of().( |
| 242 | parser_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/parser_of().(parent, bin_name).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().(INTERNAL_ERROR_MSGrust-analyzer cargo clap_complete 4.6.8 INTERNAL_ERROR_MSG.), |
| 243 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parent), |
| 244 | ); |
| 245 | |
| 246 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().subcommand_args.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() { |
| 247 | segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(subcommand_args); |
| 248 | } |
| 249 | |
| 250 | // Get the help text of all child subcommands. |
| 251 | let children = get_subcommands_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/get_subcommands_of().(parser_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/parser_of().(parent, bin_name).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().(INTERNAL_ERROR_MSGrust-analyzer cargo clap_complete 4.6.8 INTERNAL_ERROR_MSG.)); |
| 252 | |
| 253 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().children.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() { |
| 254 | segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(children); |
| 255 | } |
| 256 | |
| 257 | segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().(";;")); |
| 258 | all_subcommands.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(segments.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\n")); |
| 259 | } |
| 260 | |
| 261 | let parent_bin_name = parent |
| 262 | .get_bin_namerust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_bin_name().() |
| 263 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("crate::generate should have set the bin_name"); |
| 264 | |
| 265 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 266 | " |
| 267 | case $state in |
| 268 | ({name}) |
| 269 | words=($line[{pos}] \"${{words[@]}}\") |
| 270 | (( CURRENT += 1 )) |
| 271 | curcontext=\"${{curcontext%:*:*}}:{name_hyphen}-command-$line[{pos}]:\" |
| 272 | case $line[{pos}] in |
| 273 | {subcommands} |
| 274 | esac |
| 275 | ;; |
| 276 | esac", |
| 277 | name = parent.get_namerust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_name().(), |
| 278 | name_hyphen = parent_bin_name.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(' ', "-"), |
| 279 | subcommands = all_subcommands.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\n"), |
| 280 | pos = parent.get_positionalsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_positionals().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]count().() +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1 |
| 281 | ) |
| 282 | } |
| 283 | |
| 284 | // Get the Command for a given subcommand tree. |
| 285 | // |
| 286 | // Given the bin_name "a b c" and the Command for "a" this returns the "c" Command. |
| 287 | // Given the bin_name "a b c" and the Command for "b" this returns the "c" Command. |
| 288 | fn parser_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/parser_of().<'cmd>(parent: &'cmd Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, bin_name: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'cmd Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#> { |
| 289 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("parser_of: p={}, bin_name={}", parent.get_name(), bin_name); |
| 290 | |
| 291 | if bin_name rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().parent.get_bin_namerust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_bin_name().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().() { |
| 292 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parent); |
| 293 | } |
| 294 | |
| 295 | for subcommand in parent.get_subcommandsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_subcommands().() { |
| 296 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ret) = parser_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/parser_of().(subcommand, bin_name) { |
| 297 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ret); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 302 | } |
| 303 | |
| 304 | // Writes out the args section, which ends up being the flags, opts and positionals, and a jump to |
| 305 | // another ZSH function if there are subcommands. |
| 306 | // The structure works like this: |
| 307 | // ([conflicting_args]) [multiple] arg [takes_value] [[help]] [: :(possible_values)] |
| 308 | // ^-- list '-v -h' ^--'*' ^--'+' ^-- list 'one two three' |
| 309 | // |
| 310 | // An example from the rustup command: |
| 311 | // |
| 312 | // _arguments -C -s -S \ |
| 313 | // '(-h --help --verbose)-v[Enable verbose output]' \ |
| 314 | // '(-V -v --version --verbose --help)-h[Print help information]' \ |
| 315 | // # ... snip for brevity |
| 316 | // ':: :_rustup_commands' \ # <-- displays subcommands |
| 317 | // '*::: :->rustup' \ # <-- displays subcommand args and child subcommands |
| 318 | // && ret=0 |
| 319 | // |
| 320 | // The args used for _arguments are as follows: |
| 321 | // -C: modify the $context internal variable |
| 322 | // -s: Allow stacking of short args (i.e. -a -b -c => -abc) |
| 323 | // -S: Do not complete anything after '--' and treat those as argument values |
| 324 | fn get_args_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/get_args_of().(parent: &Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, p_global: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#>) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 325 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("get_args_of"); |
| 326 | |
| 327 | let mut segments = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("_arguments \"${_arguments_options[@]}\" : \\")]; |
| 328 | let opts = write_opts_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/write_opts_of().(parent, p_global); |
| 329 | let flags = write_flags_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/write_flags_of().(parent, p_global); |
| 330 | let positionals = write_positionals_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/write_positionals_of().(parent); |
| 331 | |
| 332 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().opts.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() { |
| 333 | segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(opts); |
| 334 | } |
| 335 | |
| 336 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().flags.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() { |
| 337 | segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(flags); |
| 338 | } |
| 339 | |
| 340 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().positionals.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() { |
| 341 | segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(positionals); |
| 342 | } |
| 343 | |
| 344 | if parent.has_subcommandsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]has_subcommands().() { |
| 345 | let parent_bin_name = parent |
| 346 | .get_bin_namerust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_bin_name().() |
| 347 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("crate::generate should have set the bin_name"); |
| 348 | let subcommand_bin_name = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 349 | "\":: :_{name}_commands\" \\", |
| 350 | name = parent_bin_name.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(' ', CMD_SEPrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/CMD_SEP.) |
| 351 | ); |
| 352 | segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(subcommand_bin_name); |
| 353 | |
| 354 | let subcommand_text = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("\"*::: :->{name}\" \\", name = parent.get_namerust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_name().()); |
| 355 | segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(subcommand_text); |
| 356 | } else if parent.is_allow_external_subcommands_setrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]is_allow_external_subcommands_set().() { |
| 357 | // If the command has an external subcommand value parser, we need to |
| 358 | // add a catch-all for the subcommand. Otherwise there would be no autocompletion whatsoever. |
| 359 | segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("\"*::external_command:_default\" \\")); |
| 360 | } |
| 361 | |
| 362 | segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("&& ret=0")); |
| 363 | segments.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\n") |
| 364 | } |
| 365 | |
| 366 | // Uses either `possible_vals` or `value_hint` to give hints about possible argument values |
| 367 | fn value_completionrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/value_completion().(arg: &Argrust-analyzer cargo clap_builder 4.6.6 builder/arg/Arg#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 368 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(values) = utilsrust-analyzer cargo clap_complete 4.6.8 aot/generator/utils/::possible_valuesrust-analyzer cargo clap_complete 4.6.8 aot/generator/utils/possible_values().(arg) { |
| 369 | if values |
| 370 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 371 | .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|value| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().value.is_hide_setrust-analyzer cargo clap_builder 4.6.6 builder/possible_value/impl#[PossibleValue]is_hide_set().() && value.get_helprust-analyzer cargo clap_builder 4.6.6 builder/possible_value/impl#[PossibleValue]get_help().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()) |
| 372 | { |
| 373 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 374 | "(({}))", |
| 375 | values |
| 376 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 377 | .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|value| { |
| 378 | if value.is_hide_setrust-analyzer cargo clap_builder 4.6.6 builder/possible_value/impl#[PossibleValue]is_hide_set().() { |
| 379 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 380 | } else { |
| 381 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 382 | r#"{name}\:"{tooltip}""#, |
| 383 | name = escape_valuerust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_value().(value.get_namerust-analyzer cargo clap_builder 4.6.6 builder/possible_value/impl#[PossibleValue]get_name().()), |
| 384 | tooltip = |
| 385 | escape_helprust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_help().(&value.get_helprust-analyzer cargo clap_builder 4.6.6 builder/possible_value/impl#[PossibleValue]get_help().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 386 | )) |
| 387 | } |
| 388 | }) |
| 389 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>() |
| 390 | .joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\n") |
| 391 | )) |
| 392 | } else { |
| 393 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 394 | "({})", |
| 395 | values |
| 396 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 397 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|pv| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().pv.is_hide_setrust-analyzer cargo clap_builder 4.6.6 builder/possible_value/impl#[PossibleValue]is_hide_set().()) |
| 398 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|n| n.get_namerust-analyzer cargo clap_builder 4.6.6 builder/possible_value/impl#[PossibleValue]get_name().()) |
| 399 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>() |
| 400 | .joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().(" ") |
| 401 | )) |
| 402 | } |
| 403 | } else { |
| 404 | // NB! If you change this, please also update the table in `ValueHint` documentation. |
| 405 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#( |
| 406 | match arg.get_value_hintrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_value_hint().() { |
| 407 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::Unknownrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#Unknown# => "_default", |
| 408 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::Otherrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#Other# => "", |
| 409 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::AnyPathrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#AnyPath# => "_files", |
| 410 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::FilePathrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#FilePath# => "_files", |
| 411 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::DirPathrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#DirPath# => "_files -/", |
| 412 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::ExecutablePathrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#ExecutablePath# => "_absolute_command_paths", |
| 413 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::CommandNamerust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#CommandName# => "_command_names -e", |
| 414 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::CommandStringrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#CommandString# => "_cmdstring", |
| 415 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::CommandWithArgumentsrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#CommandWithArguments# => "_cmdambivalent", |
| 416 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::Usernamerust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#Username# => "_users", |
| 417 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::Hostnamerust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#Hostname# => "_hosts", |
| 418 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::Urlrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#Url# => "_urls", |
| 419 | ValueHintrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#::EmailAddressrust-analyzer cargo clap_builder 4.6.6 builder/value_hint/ValueHint#EmailAddress# => "_email_addresses", |
| 420 | _ => { |
| 421 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 422 | } |
| 423 | } |
| 424 | .to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 425 | ) |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | /// Escape help string inside single quotes and brackets |
| 430 | fn escape_helprust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_help().(string: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 431 | string |
| 432 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('\\', "\\\\") |
| 433 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('\'', "'\\''") |
| 434 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('[', "\\[") |
| 435 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(']', "\\]") |
| 436 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(':', "\\:") |
| 437 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('$', "\\$") |
| 438 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('`', "\\`") |
| 439 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('\n', " ") |
| 440 | } |
| 441 | |
| 442 | /// Escape value string inside single quotes and parentheses |
| 443 | fn escape_valuerust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_value().(string: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 444 | string |
| 445 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('\\', "\\\\") |
| 446 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('\'', "'\\''") |
| 447 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('[', "\\[") |
| 448 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(']', "\\]") |
| 449 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(':', "\\:") |
| 450 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('$', "\\$") |
| 451 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('`', "\\`") |
| 452 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('(', "\\(") |
| 453 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(')', "\\)") |
| 454 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(' ', "\\ ") |
| 455 | } |
| 456 | |
| 457 | fn write_opts_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/write_opts_of().(p: &Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, p_global: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#>) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 458 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_opts_of"); |
| 459 | |
| 460 | let mut ret = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 461 | |
| 462 | for o in p.get_optsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_opts().() { |
| 463 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_opts_of:iter: o={}", o.get_id()); |
| 464 | |
| 465 | let help = escape_helprust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_help().(&o.get_helprust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_help().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 466 | let conflicts = arg_conflictsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/arg_conflicts().(p, o, p_global); |
| 467 | |
| 468 | let multiple = if let ArgActionrust-analyzer cargo clap_builder 4.6.6 builder/action/ArgAction#::Countrust-analyzer cargo clap_builder 4.6.6 builder/action/ArgAction#Count# | ArgActionrust-analyzer cargo clap_builder 4.6.6 builder/action/ArgAction#::Appendrust-analyzer cargo clap_builder 4.6.6 builder/action/ArgAction#Append# = o.get_actionrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_action().() { |
| 469 | "*" |
| 470 | } else { |
| 471 | "" |
| 472 | }; |
| 473 | |
| 474 | let vn = match o.get_value_namesrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_value_names().() { |
| 475 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => " ".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 476 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) => val[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 477 | }; |
| 478 | let vc = match value_completionrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/value_completion().(o) { |
| 479 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(":{vn}:{val}"), |
| 480 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(":{vn}: "), |
| 481 | }; |
| 482 | let vc = match o.get_num_argsrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_num_args().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("built").min_valuesrust-analyzer cargo clap_builder 4.6.6 builder/range/impl#[ValueRange]min_values().() { |
| 483 | 0 => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(":{vc}"), |
| 484 | min_value => vc.repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(min_value), |
| 485 | }; |
| 486 | |
| 487 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(shorts) = o.get_short_and_visible_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_short_and_visible_aliases().() { |
| 488 | for short in shorts { |
| 489 | let s = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("'{conflicts}{multiple}-{short}+[{help}]{vc}' \\"); |
| 490 | |
| 491 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_opts_of:iter: Wrote...{}", &*s); |
| 492 | ret.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(s); |
| 493 | } |
| 494 | } |
| 495 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(longs) = o.get_long_and_visible_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_long_and_visible_aliases().() { |
| 496 | for long in longs { |
| 497 | let l = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("'{conflicts}{multiple}--{long}=[{help}]{vc}' \\"); |
| 498 | |
| 499 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_opts_of:iter: Wrote...{}", &*l); |
| 500 | ret.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(l); |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | ret.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\n") |
| 506 | } |
| 507 | |
| 508 | fn arg_conflictsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/arg_conflicts().(cmd: &Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, arg: &Argrust-analyzer cargo clap_builder 4.6.6 builder/arg/Arg#, app_global: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#>) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 509 | fn push_conflictsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/push_conflicts().(conflicts: &[&Argrust-analyzer cargo clap_builder 4.6.6 builder/arg/Arg#], res: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) { |
| 510 | for conflict in conflicts { |
| 511 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) = conflict.get_shortrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_short().() { |
| 512 | res.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("-{s}")); |
| 513 | } |
| 514 | |
| 515 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(l) = conflict.get_longrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_long().() { |
| 516 | res.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("--{l}")); |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | let mut res = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 522 | match (app_global, arg.is_global_setrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]is_global_set().()) { |
| 523 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x), true) => { |
| 524 | let conflicts = x.get_arg_conflicts_withrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_arg_conflicts_with().(arg); |
| 525 | |
| 526 | if conflicts.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 527 | return Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 528 | } |
| 529 | |
| 530 | push_conflictsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/push_conflicts().(&conflicts, &mut res); |
| 531 | } |
| 532 | (_, _) => { |
| 533 | let conflicts = cmd.get_arg_conflicts_withrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_arg_conflicts_with().(arg); |
| 534 | |
| 535 | if conflicts.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 536 | return Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 537 | } |
| 538 | |
| 539 | push_conflictsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/push_conflicts().(&conflicts, &mut res); |
| 540 | } |
| 541 | }; |
| 542 | |
| 543 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("({})", res.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().(" ")) |
| 544 | } |
| 545 | |
| 546 | fn write_flags_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/write_flags_of().(p: &Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, p_global: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#>) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 547 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_flags_of;"); |
| 548 | |
| 549 | let mut ret = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 550 | |
| 551 | for f in utilsrust-analyzer cargo clap_complete 4.6.8 aot/generator/utils/::flagsrust-analyzer cargo clap_complete 4.6.8 aot/generator/utils/flags().(p) { |
| 552 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_flags_of:iter: f={}", f.get_id()); |
| 553 | |
| 554 | let help = escape_helprust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_help().(&f.get_helprust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_help().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 555 | let conflicts = arg_conflictsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/arg_conflicts().(p, &f, p_global); |
| 556 | |
| 557 | let multiple = if let ArgActionrust-analyzer cargo clap_builder 4.6.6 builder/action/ArgAction#::Countrust-analyzer cargo clap_builder 4.6.6 builder/action/ArgAction#Count# | ArgActionrust-analyzer cargo clap_builder 4.6.6 builder/action/ArgAction#::Appendrust-analyzer cargo clap_builder 4.6.6 builder/action/ArgAction#Append# = f.get_actionrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_action().() { |
| 558 | "*" |
| 559 | } else { |
| 560 | "" |
| 561 | }; |
| 562 | |
| 563 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(short) = f.get_shortrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_short().() { |
| 564 | let s = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("'{conflicts}{multiple}-{short}[{help}]' \\"); |
| 565 | |
| 566 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_flags_of:iter: Wrote...{}", &*s); |
| 567 | |
| 568 | ret.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(s); |
| 569 | |
| 570 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(short_aliases) = f.get_visible_short_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_visible_short_aliases().() { |
| 571 | for alias in short_aliases { |
| 572 | let s = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("'{conflicts}{multiple}-{alias}[{help}]' \\",); |
| 573 | |
| 574 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_flags_of:iter: Wrote...{}", &*s); |
| 575 | |
| 576 | ret.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(s); |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(long) = f.get_longrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_long().() { |
| 582 | let l = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("'{conflicts}{multiple}--{long}[{help}]' \\"); |
| 583 | |
| 584 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_flags_of:iter: Wrote...{}", &*l); |
| 585 | |
| 586 | ret.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(l); |
| 587 | |
| 588 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(aliases) = f.get_visible_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_visible_aliases().() { |
| 589 | for alias in aliases { |
| 590 | let l = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("'{conflicts}{multiple}--{alias}[{help}]' \\"); |
| 591 | |
| 592 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_flags_of:iter: Wrote...{}", &*l); |
| 593 | |
| 594 | ret.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(l); |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | ret.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\n") |
| 601 | } |
| 602 | |
| 603 | fn write_positionals_ofrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/write_positionals_of().(p: &Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 604 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_positionals_of;"); |
| 605 | |
| 606 | let mut ret = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 607 | |
| 608 | // Completions for commands that end with two Vec arguments require special care. |
| 609 | // - You can have two Vec args separated with a custom value terminator. |
| 610 | // - You can have two Vec args with the second one set to last (raw sets last) |
| 611 | // which will require a '--' separator to be used before the second argument |
| 612 | // on the command-line. |
| 613 | // |
| 614 | // We use the '-S' _arguments option to disable completion after '--'. Thus, the |
| 615 | // completion for the second argument in scenario (B) does not need to be emitted |
| 616 | // because it is implicitly handled by the '-S' option. |
| 617 | // We only need to emit the first catch-all. |
| 618 | // |
| 619 | // Have we already emitted a catch-all multi-valued positional argument |
| 620 | // without a custom value terminator? |
| 621 | let mut catch_all_emitted = false; |
| 622 | |
| 623 | for arg in p.get_positionalsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_positionals().() { |
| 624 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_positionals_of:iter: arg={}", arg.get_id()); |
| 625 | |
| 626 | let num_args = arg.get_num_argsrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_num_args().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("built"); |
| 627 | let is_multi_valued = num_args.max_valuesrust-analyzer cargo clap_builder 4.6.6 builder/range/impl#[ValueRange]max_values().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().1; |
| 628 | |
| 629 | if catch_all_emitted && (arg.is_last_setrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]is_last_set().() || is_multi_valued) { |
| 630 | // This is the final argument and it also takes multiple arguments. |
| 631 | // We've already emitted a catch-all positional argument so we don't need |
| 632 | // to emit anything for this argument because it is implicitly handled by |
| 633 | // the use of the '-S' _arguments option. |
| 634 | continue; |
| 635 | } |
| 636 | |
| 637 | let cardinality_value; |
| 638 | // If we have any subcommands, we'll emit a catch-all argument, so we shouldn't |
| 639 | // emit one here. |
| 640 | let cardinality = if is_multi_valued && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().p.has_subcommandsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]has_subcommands().() { |
| 641 | match arg.get_value_terminatorrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_value_terminator().() { |
| 642 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(terminator) => { |
| 643 | cardinality_value = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("*{}:", escape_valuerust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_value().(terminator)); |
| 644 | cardinality_value.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() |
| 645 | } |
| 646 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 647 | catch_all_emitted = true; |
| 648 | "*:" |
| 649 | } |
| 650 | } |
| 651 | } else if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().arg.is_required_setrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]is_required_set().() { |
| 652 | ":" |
| 653 | } else { |
| 654 | "" |
| 655 | }; |
| 656 | |
| 657 | let a = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 658 | "'{cardinality}:{name}{help}:{value_completion}' \\", |
| 659 | cardinality = cardinality, |
| 660 | name = arg.get_idrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_id().(), |
| 661 | help = arg |
| 662 | .get_helprust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_help().() |
| 663 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 664 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(" -- {v}")) |
| 665 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| "".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 666 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('[', "\\[") |
| 667 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(']', "\\]") |
| 668 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('\'', "'\\''") |
| 669 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(':', "\\:"), |
| 670 | value_completion = value_completionrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/value_completion().(arg).unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().() |
| 671 | ); |
| 672 | |
| 673 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("write_positionals_of:iter: Wrote...{a}"); |
| 674 | |
| 675 | ret.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(a); |
| 676 | } |
| 677 | |
| 678 | ret.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\n") |
| 679 | } |
| 680 | |
| 681 | const CMD_SEPrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/CMD_SEP.: &str = "__subcmd__"; |
| 682 | |
| 683 | #[cfg(test)] |
| 684 | mod testsrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/tests/ { |
| 685 | use superrust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/::{escape_helprust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_help()., escape_valuerust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_value().}; |
| 686 | |
| 687 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 688 | fn test_escape_valuerust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/tests/test_escape_value().() { |
| 689 | let raw_string = "\\ [foo]() `bar https://$PATH"; |
| 690 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 691 | escape_valuerust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_value().(raw_string), |
| 692 | "\\\\\\ \\[foo\\]\\(\\)\\ \\`bar\\ https\\://\\$PATH" |
| 693 | ); |
| 694 | } |
| 695 | |
| 696 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 697 | fn test_escape_helprust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/tests/test_escape_help().() { |
| 698 | let raw_string = "\\ [foo]() `bar https://$PATH"; |
| 699 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 700 | escape_helprust-analyzer cargo clap_complete 4.6.8 aot/shells/zsh/escape_help().(raw_string), |
| 701 | "\\\\ \\[foo\\]() \\`bar https\\://\\$PATH" |
| 702 | ); |
| 703 | } |
| 704 | } |