| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#; |
| 3 | |
| 4 | use clap_lexrust-analyzer cargo clap_lex 1.0.0 crate/::OsStrExtrust-analyzer cargo clap_lex 1.0.0 ext/OsStrExt# as _; |
| 5 | |
| 6 | use superrust-analyzer cargo clap_complete 4.6.8 engine/::ArgValueCandidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/ArgValueCandidates#; |
| 7 | use superrust-analyzer cargo clap_complete 4.6.8 engine/::ArgValueCompleterrust-analyzer cargo clap_complete 4.6.8 engine/custom/ArgValueCompleter#; |
| 8 | use superrust-analyzer cargo clap_complete 4.6.8 engine/::CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#; |
| 9 | use superrust-analyzer cargo clap_complete 4.6.8 engine/::SubcommandCandidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/SubcommandCandidates#; |
| 10 | use superrust-analyzer cargo clap_complete 4.6.8 engine/::ValueCandidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/ValueCandidates#; |
| 11 | use superrust-analyzer cargo clap_complete 4.6.8 engine/::customrust-analyzer cargo clap_complete 4.6.8 engine/custom/::complete_pathrust-analyzer cargo clap_complete 4.6.8 engine/custom/complete_path().; |
| 12 | use superrust-analyzer cargo clap_complete 4.6.8 engine/::customrust-analyzer cargo clap_complete 4.6.8 engine/custom/::possible_value_candidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/possible_value_candidates().; |
| 13 | |
| 14 | /// Complete the given command, shell-agnostic |
| 15 | pub fn completerust-analyzer cargo clap_complete 4.6.8 engine/complete/complete().( |
| 16 | cmd: &mut claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, |
| 17 | args: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#>, |
| 18 | arg_index: usize, |
| 19 | current_dir: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>, |
| 20 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#>, 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#> { |
| 21 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("complete: args={args:?}, arg_index={arg_index:?}, current_dir={current_dir:?}"); |
| 22 | cmd.buildrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]build().(); |
| 23 | |
| 24 | let raw_args = clap_lexrust-analyzer cargo clap_lex 1.0.0 crate/::RawArgsrust-analyzer cargo clap_lex 1.0.0 RawArgs#::newrust-analyzer cargo clap_lex 1.0.0 impl#[RawArgs]new().(args); |
| 25 | let mut cursor = raw_args.cursorrust-analyzer cargo clap_lex 1.0.0 impl#[RawArgs]cursor().(); |
| 26 | let mut target_cursor = raw_args.cursorrust-analyzer cargo clap_lex 1.0.0 impl#[RawArgs]cursor().(); |
| 27 | raw_args.seekrust-analyzer cargo clap_lex 1.0.0 impl#[RawArgs]seek().( |
| 28 | &mut target_cursor, |
| 29 | clap_lexrust-analyzer cargo clap_lex 1.0.0 crate/::SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(arg_index as u64), |
| 30 | ); |
| 31 | // As we loop, `cursor` will always be pointing to the next item |
| 32 | raw_args.next_osrust-analyzer cargo clap_lex 1.0.0 impl#[RawArgs]next_os().(&mut target_cursor); |
| 33 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("complete: target_cursor={target_cursor:?}"); |
| 34 | |
| 35 | // TODO: Multicall support |
| 36 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().cmd.is_no_binary_name_setrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]is_no_binary_name_set().() { |
| 37 | raw_args.next_osrust-analyzer cargo clap_lex 1.0.0 impl#[RawArgs]next_os().(&mut cursor); |
| 38 | } |
| 39 | |
| 40 | let mut current_cmd = &*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().cmd; |
| 41 | let mut pos_index = 1; |
| 42 | let mut is_escaped = false; |
| 43 | let mut next_state = ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::ValueDonerust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#ValueDone#; |
| 44 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(arg) = raw_args.nextrust-analyzer cargo clap_lex 1.0.0 impl#[RawArgs]next().(&mut cursor) { |
| 45 | let current_state = next_state; |
| 46 | next_state = ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::ValueDonerust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#ValueDone#; |
| 47 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!( |
| 48 | "complete::next: arg={:?}, current_state={current_state:?}, cursor={cursor:?}", |
| 49 | arg.to_value_os(), |
| 50 | ); |
| 51 | if cursor rust-analyzer cargo clap_lex 1.0.0 impl#[ArgCursor][`PartialEq<Self>`]eq().==rust-analyzer cargo clap_lex 1.0.0 impl#[ArgCursor][`PartialEq<Self>`]eq(). rust-analyzer cargo clap_lex 1.0.0 impl#[ArgCursor][`PartialEq<Self>`]eq().target_cursor { |
| 52 | return complete_argrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_arg().( |
| 53 | &arg, |
| 54 | current_cmd, |
| 55 | current_dir, |
| 56 | pos_index, |
| 57 | is_escaped, |
| 58 | current_state, |
| 59 | ); |
| 60 | } |
| 61 | |
| 62 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value) = arg.to_valuerust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_value().() { |
| 63 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(next_cmd) = current_cmd.find_subcommandrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]find_subcommand().(value) { |
| 64 | current_cmd = next_cmd; |
| 65 | pos_index = 1; |
| 66 | continue; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | if is_escaped { |
| 71 | (next_state, pos_index) = |
| 72 | parse_positionalrust-analyzer cargo clap_complete 4.6.8 engine/complete/parse_positional().(current_cmd, pos_index, is_escaped, current_state); |
| 73 | } else if arg.is_escaperust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]is_escape().() { |
| 74 | is_escaped = true; |
| 75 | } else if opt_allows_hyphenrust-analyzer cargo clap_complete 4.6.8 engine/complete/opt_allows_hyphen().(¤t_state, &arg) { |
| 76 | match current_state { |
| 77 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Optrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Opt#((opt, count)) => next_state = parse_opt_valuerust-analyzer cargo clap_complete 4.6.8 engine/complete/parse_opt_value().(opt, count), |
| 78 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("else branch is only reachable in Opt state"), |
| 79 | } |
| 80 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((flag, value)) = arg.to_longrust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_long().() { |
| 81 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(flag) = flag { |
| 82 | let opt = current_cmd.get_argumentsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_arguments().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]find().(|a| { |
| 83 | let longs = a.get_long_and_visible_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_long_and_visible_aliases().(); |
| 84 | let is_find = longs.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| { |
| 85 | let mut iter = v.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(); |
| 86 | let s = iter.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|s| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().s 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().flag); |
| 87 | s.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() |
| 88 | }); |
| 89 | is_find.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) |
| 90 | }); |
| 91 | |
| 92 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(opt) = opt { |
| 93 | if opt.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").takes_valuesrust-analyzer cargo clap_builder 4.6.6 builder/range/impl#[ValueRange]takes_values().() && value.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 94 | next_state = ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Optrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Opt#((opt, 1)); |
| 95 | }; |
| 96 | } else if pos_allows_hyphenrust-analyzer cargo clap_complete 4.6.8 engine/complete/pos_allows_hyphen().(current_cmd, pos_index) { |
| 97 | (next_state, pos_index) = |
| 98 | parse_positionalrust-analyzer cargo clap_complete 4.6.8 engine/complete/parse_positional().(current_cmd, pos_index, is_escaped, current_state); |
| 99 | } |
| 100 | } |
| 101 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(short) = arg.to_shortrust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_short().() { |
| 102 | let (_, takes_value_opt, mut short) = parse_shortflagsrust-analyzer cargo clap_complete 4.6.8 engine/complete/parse_shortflags().(current_cmd, short); |
| 103 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(opt) = takes_value_opt { |
| 104 | if short.next_value_osrust-analyzer cargo clap_lex 1.0.0 impl#[`ShortFlags<'s>`]next_value_os().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 105 | next_state = ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Optrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Opt#((opt, 1)); |
| 106 | } |
| 107 | } else if pos_allows_hyphenrust-analyzer cargo clap_complete 4.6.8 engine/complete/pos_allows_hyphen().(current_cmd, pos_index) { |
| 108 | (next_state, pos_index) = |
| 109 | parse_positionalrust-analyzer cargo clap_complete 4.6.8 engine/complete/parse_positional().(current_cmd, pos_index, is_escaped, current_state); |
| 110 | } |
| 111 | } else { |
| 112 | match current_state { |
| 113 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::ValueDonerust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#ValueDone# | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Posrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Pos#(..) => { |
| 114 | (next_state, pos_index) = |
| 115 | parse_positionalrust-analyzer cargo clap_complete 4.6.8 engine/complete/parse_positional().(current_cmd, pos_index, is_escaped, current_state); |
| 116 | } |
| 117 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Optrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Opt#((opt, count)) => next_state = parse_opt_valuerust-analyzer cargo clap_complete 4.6.8 engine/complete/parse_opt_value().(opt, count), |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(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#::otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]other().("no completion generated")) |
| 123 | } |
| 124 | |
| 125 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, 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:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 126 | enum ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#<'a> { |
| 127 | /// Parsing a value done, there is no state to record. |
| 128 | ValueDonerust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#ValueDone#, |
| 129 | |
| 130 | /// Parsing a positional argument after `--`. `Pos(pos_index`, `takes_num_args`) |
| 131 | Posrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Pos#((usize, usize)), |
| 132 | |
| 133 | /// Parsing a optional flag argument |
| 134 | Optrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Opt#((&'a claprust-analyzer cargo clap 4.6.6 crate/::Argrust-analyzer cargo clap_builder 4.6.6 builder/arg/Arg#, usize)), |
| 135 | } |
| 136 | |
| 137 | fn complete_argrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_arg().( |
| 138 | arg: &clap_lexrust-analyzer cargo clap_lex 1.0.0 crate/::ParsedArgrust-analyzer cargo clap_lex 1.0.0 ParsedArg#<'_>, |
| 139 | cmd: &claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, |
| 140 | current_dir: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>, |
| 141 | pos_index: usize, |
| 142 | is_escaped: bool, |
| 143 | state: ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#<'_>, |
| 144 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#>, 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#> { |
| 145 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!( |
| 146 | "complete_arg: arg={:?}, cmd={:?}, current_dir={:?}, pos_index={:?}, state={:?}", |
| 147 | arg, |
| 148 | cmd.get_name(), |
| 149 | current_dir, |
| 150 | pos_index, |
| 151 | state |
| 152 | ); |
| 153 | let mut completions = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 154 | |
| 155 | match state { |
| 156 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::ValueDonerust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#ValueDone# => { |
| 157 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value) = arg.to_valuerust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_value().() { |
| 158 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_subcommandrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_subcommand().(value, cmd)); |
| 159 | } |
| 160 | |
| 161 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(positional) = cmd |
| 162 | .get_positionalsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_positionals().() |
| 163 | .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|p| p.get_indexrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_index().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pos_index)) |
| 164 | { |
| 165 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_arg_valuerust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_arg_value().( |
| 166 | arg.to_valuerust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_value().(), |
| 167 | positional, |
| 168 | current_dir, |
| 169 | 0, |
| 170 | )); |
| 171 | } |
| 172 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_escaped { |
| 173 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_optionrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_option().(arg, cmd, current_dir)); |
| 174 | } |
| 175 | } |
| 176 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Posrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Pos#((_, num_arg)) => { |
| 177 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(positional) = cmd |
| 178 | .get_positionalsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_positionals().() |
| 179 | .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|p| p.get_indexrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_index().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pos_index)) |
| 180 | { |
| 181 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_arg_valuerust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_arg_value().( |
| 182 | arg.to_valuerust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_value().(), |
| 183 | positional, |
| 184 | current_dir, |
| 185 | num_arg.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(1), |
| 186 | )); |
| 187 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_escaped |
| 188 | && positional |
| 189 | .get_num_argsrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_num_args().() |
| 190 | .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|num_args| num_arg rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().num_args.min_valuesrust-analyzer cargo clap_builder 4.6.6 builder/range/impl#[ValueRange]min_values().()) |
| 191 | { |
| 192 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_optionrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_option().(arg, cmd, current_dir)); |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Optrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Opt#((opt, count)) => { |
| 197 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_arg_valuerust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_arg_value().( |
| 198 | arg.to_valuerust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_value().(), |
| 199 | opt, |
| 200 | current_dir, |
| 201 | count.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(1), |
| 202 | )); |
| 203 | let min = opt.get_num_argsrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_num_args().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|r| r.min_valuesrust-analyzer cargo clap_builder 4.6.6 builder/range/impl#[ValueRange]min_values().()).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0); |
| 204 | if count 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().min { |
| 205 | // Also complete this raw_arg as a positional argument, flags, options and subcommand. |
| 206 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_argrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_arg().( |
| 207 | arg, |
| 208 | cmd, |
| 209 | current_dir, |
| 210 | pos_index, |
| 211 | is_escaped, |
| 212 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::ValueDonerust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#ValueDone#, |
| 213 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | if completions.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|a| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().a.is_hide_setrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]is_hide_set().()) { |
| 218 | completions.retainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]retain().(|a| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().a.is_hide_setrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]is_hide_set().()); |
| 219 | } |
| 220 | let mut seen_ids = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().(); |
| 221 | completions.retainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]retain().(move |a| { |
| 222 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(id) = a.get_idrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]get_id().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().() { |
| 223 | seen_ids.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(id) |
| 224 | } else { |
| 225 | true |
| 226 | } |
| 227 | }); |
| 228 | |
| 229 | let mut tags = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 230 | for candidate in &completions { |
| 231 | let tag = candidate.get_tagrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]get_tag().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().(); |
| 232 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().tags.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&tag) { |
| 233 | tags.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(tag); |
| 234 | } |
| 235 | } |
| 236 | completions.sort_by_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort_by_key().(|c| { |
| 237 | ( |
| 238 | tags.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]position().(|t| c.get_tagrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]get_tag().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().t.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()), |
| 239 | c.get_display_orderrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]get_display_order().(), |
| 240 | ) |
| 241 | }); |
| 242 | |
| 243 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(completions) |
| 244 | } |
| 245 | |
| 246 | fn complete_optionrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_option().( |
| 247 | arg: &clap_lexrust-analyzer cargo clap_lex 1.0.0 crate/::ParsedArgrust-analyzer cargo clap_lex 1.0.0 ParsedArg#<'_>, |
| 248 | cmd: &claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, |
| 249 | current_dir: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>, |
| 250 | ) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#> { |
| 251 | let mut completions = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 252 | if arg.is_emptyrust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]is_empty().() { |
| 253 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(longs_and_visible_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/longs_and_visible_aliases().(cmd)); |
| 254 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(hidden_longs_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/hidden_longs_aliases().(cmd)); |
| 255 | |
| 256 | let dash_or_arg = if arg.is_emptyrust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]is_empty().() { |
| 257 | "-".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 258 | } else { |
| 259 | arg.to_value_osrust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_value_os().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().() |
| 260 | }; |
| 261 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().( |
| 262 | shorts_and_visible_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/shorts_and_visible_aliases().(cmd) |
| 263 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 264 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|comp| comp.add_prefixrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]add_prefix().(dash_or_arg.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 265 | ); |
| 266 | } else if arg.is_stdiorust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]is_stdio().() { |
| 267 | // HACK: Assuming knowledge of is_stdio |
| 268 | let dash_or_arg = if arg.is_emptyrust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]is_empty().() { |
| 269 | "-".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 270 | } else { |
| 271 | arg.to_value_osrust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_value_os().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().() |
| 272 | }; |
| 273 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().( |
| 274 | shorts_and_visible_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/shorts_and_visible_aliases().(cmd) |
| 275 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 276 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|comp| comp.add_prefixrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]add_prefix().(dash_or_arg.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 277 | ); |
| 278 | |
| 279 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(longs_and_visible_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/longs_and_visible_aliases().(cmd)); |
| 280 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(hidden_longs_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/hidden_longs_aliases().(cmd)); |
| 281 | } else if arg.is_escaperust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]is_escape().() { |
| 282 | // HACK: Assuming knowledge of is_escape |
| 283 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(longs_and_visible_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/longs_and_visible_aliases().(cmd)); |
| 284 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(hidden_longs_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/hidden_longs_aliases().(cmd)); |
| 285 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((flag, value)) = arg.to_longrust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_long().() { |
| 286 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(flag) = flag { |
| 287 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value) = value { |
| 288 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(arg) = cmd.get_argumentsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_arguments().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]find().(|a| a.get_longrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_long().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(flag)) { |
| 289 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().( |
| 290 | complete_arg_valuerust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_arg_value().(value.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().().ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(value), arg, current_dir, 0) |
| 291 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 292 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|comp| comp.add_prefixrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]add_prefix().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("--{flag}="))), |
| 293 | ); |
| 294 | } |
| 295 | } else { |
| 296 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().( |
| 297 | longs_and_visible_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/longs_and_visible_aliases().(cmd) |
| 298 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 299 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|comp| comp.get_valuerust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]get_value().().starts_withrust-analyzer cargo clap_lex 1.0.0 ext/impl#[OsStr][OsStrExt]starts_with().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("--{flag}").as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().())), |
| 300 | ); |
| 301 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().( |
| 302 | hidden_longs_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/hidden_longs_aliases().(cmd) |
| 303 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 304 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|comp| comp.get_valuerust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]get_value().().starts_withrust-analyzer cargo clap_lex 1.0.0 ext/impl#[OsStr][OsStrExt]starts_with().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("--{flag}").as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().())), |
| 305 | ); |
| 306 | } |
| 307 | } |
| 308 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(short) = arg.to_shortrust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_short().() { |
| 309 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().short.is_negative_numberrust-analyzer cargo clap_lex 1.0.0 impl#[`ShortFlags<'s>`]is_negative_number().() { |
| 310 | // Find the first takes_values option. |
| 311 | let (leading_flags, takes_value_opt, mut short) = parse_shortflagsrust-analyzer cargo clap_complete 4.6.8 engine/complete/parse_shortflags().(cmd, short); |
| 312 | |
| 313 | // Clone `short` to `peek_short` to peek whether the next flag is a `=`. |
| 314 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(opt) = takes_value_opt { |
| 315 | let mut peek_short = short.clonerust-analyzer cargo clap_lex 1.0.0 impl#[`ShortFlags<'s>`][Clone]clone().(); |
| 316 | let has_equal = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#('=')) = peek_short.next_flagrust-analyzer cargo clap_lex 1.0.0 impl#[`ShortFlags<'s>`]next_flag().() { |
| 317 | short.next_flagrust-analyzer cargo clap_lex 1.0.0 impl#[`ShortFlags<'s>`]next_flag().(); |
| 318 | true |
| 319 | } else { |
| 320 | false |
| 321 | }; |
| 322 | |
| 323 | let value = short.next_value_osrust-analyzer cargo clap_lex 1.0.0 impl#[`ShortFlags<'s>`]next_value_os().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]new().("")); |
| 324 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().( |
| 325 | complete_arg_valuerust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_arg_value().(value.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().().ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(value), opt, current_dir, 0) |
| 326 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 327 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|comp| { |
| 328 | let sep = if has_equal { "=" } else { "" }; |
| 329 | comp.add_prefixrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]add_prefix().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("-{leading_flags}{sep}")) |
| 330 | }), |
| 331 | ); |
| 332 | } else { |
| 333 | completions.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().( |
| 334 | shorts_and_visible_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/shorts_and_visible_aliases().(cmd) |
| 335 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 336 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|comp| comp.add_prefixrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]add_prefix().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("-{leading_flags}"))), |
| 337 | ); |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | completions |
| 342 | } |
| 343 | |
| 344 | fn complete_arg_valuerust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_arg_value().( |
| 345 | value: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&str, &OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#>, |
| 346 | arg: &claprust-analyzer cargo clap 4.6.6 crate/::Argrust-analyzer cargo clap_builder 4.6.6 builder/arg/Arg#, |
| 347 | current_dir: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>, |
| 348 | arg_index: usize, |
| 349 | ) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#> { |
| 350 | let mut values = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 351 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("complete_arg_value: arg={arg:?}, value={value:?}, arg_index={arg_index:?}"); |
| 352 | |
| 353 | let (prefix, value) = |
| 354 | rsplit_delimiterrust-analyzer cargo clap_complete 4.6.8 engine/complete/rsplit_delimiter().(value, arg.get_value_delimiterrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_value_delimiter().()).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().((Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, value)); |
| 355 | |
| 356 | let value_os = match value { |
| 357 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value) => OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]new().(value), |
| 358 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(value_os) => value_os, |
| 359 | }; |
| 360 | |
| 361 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(completer) = arg.getrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get().::<ArgValueCompleterrust-analyzer cargo clap_complete 4.6.8 engine/custom/ArgValueCompleter#>() { |
| 362 | values.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(completer.complete_atrust-analyzer cargo clap_complete 4.6.8 engine/custom/impl#[ArgValueCompleter]complete_at().(arg_index, value_os)); |
| 363 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(completer) = arg.getrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get().::<ArgValueCandidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/ArgValueCandidates#>() { |
| 364 | values.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_value_candidatesrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_value_candidates().( |
| 365 | value_os, |
| 366 | completer.value_candidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/impl#[ArgValueCandidates]value_candidates().(), |
| 367 | )); |
| 368 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(possible_values) = possible_valuesrust-analyzer cargo clap_complete 4.6.8 engine/complete/possible_values().(arg) { |
| 369 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value) = value { |
| 370 | values.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_candidates_strrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_candidates_str().( |
| 371 | value, |
| 372 | possible_value_candidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/possible_value_candidates().(possible_values), |
| 373 | )); |
| 374 | } |
| 375 | } else { |
| 376 | match arg.get_value_hintrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_value_hint().() { |
| 377 | claprust-analyzer cargo clap 4.6.6 crate/::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# | claprust-analyzer cargo clap 4.6.6 crate/::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# => { |
| 378 | // Should not complete |
| 379 | } |
| 380 | claprust-analyzer cargo clap 4.6.6 crate/::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# => { |
| 381 | values.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_pathrust-analyzer cargo clap_complete 4.6.8 engine/custom/complete_path().(value_os, current_dir, &|_| true)); |
| 382 | } |
| 383 | claprust-analyzer cargo clap 4.6.6 crate/::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# => { |
| 384 | values.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_pathrust-analyzer cargo clap_complete 4.6.8 engine/custom/complete_path().(value_os, current_dir, &|p| p.is_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]is_file().())); |
| 385 | } |
| 386 | claprust-analyzer cargo clap 4.6.6 crate/::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# => { |
| 387 | values.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_pathrust-analyzer cargo clap_complete 4.6.8 engine/custom/complete_path().(value_os, current_dir, &|p| p.is_dirrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]is_dir().())); |
| 388 | } |
| 389 | claprust-analyzer cargo clap 4.6.6 crate/::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# => { |
| 390 | use is_executablerust-analyzer cargo is_executable 1.0.5 crate/::IsExecutablerust-analyzer cargo is_executable 1.0.5 IsExecutable#; |
| 391 | values.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_pathrust-analyzer cargo clap_complete 4.6.8 engine/custom/complete_path().(value_os, current_dir, &|p| p.is_executablerust-analyzer cargo is_executable 1.0.5 unix/impl#[Path][IsExecutable]is_executable().())); |
| 392 | } |
| 393 | claprust-analyzer cargo clap 4.6.6 crate/::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# |
| 394 | | claprust-analyzer cargo clap 4.6.6 crate/::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# |
| 395 | | claprust-analyzer cargo clap 4.6.6 crate/::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# |
| 396 | | claprust-analyzer cargo clap 4.6.6 crate/::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# |
| 397 | | claprust-analyzer cargo clap 4.6.6 crate/::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# |
| 398 | | claprust-analyzer cargo clap 4.6.6 crate/::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# |
| 399 | | claprust-analyzer cargo clap 4.6.6 crate/::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# => { |
| 400 | // No completion implementation |
| 401 | } |
| 402 | _ => { |
| 403 | // Safe-ish fallback |
| 404 | values.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_pathrust-analyzer cargo clap_complete 4.6.8 engine/custom/complete_path().(value_os, current_dir, &|_| true)); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | values.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().(); |
| 409 | } |
| 410 | |
| 411 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prefix) = prefix { |
| 412 | values = values |
| 413 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 414 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|comp| comp.add_prefixrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]add_prefix().(prefix)) |
| 415 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 416 | } |
| 417 | values = values |
| 418 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 419 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|comp| { |
| 420 | if comp.get_tagrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]get_tag().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 421 | comp |
| 422 | } else { |
| 423 | comp.tagrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]tag().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(arg.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())) |
| 424 | } |
| 425 | }) |
| 426 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 427 | |
| 428 | values |
| 429 | } |
| 430 | |
| 431 | fn rsplit_delimiterrust-analyzer cargo clap_complete 4.6.8 engine/complete/rsplit_delimiter().<'s, 'o>( |
| 432 | value: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&'s str, &'o OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#>, |
| 433 | delimiter: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<char>, |
| 434 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'s str>, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&'s str, &'o OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#>)> { |
| 435 | let delimiter = delimiter?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 436 | let value = value.okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 437 | let pos = value.rfindrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]rfind().(delimiter)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 438 | let (prefix, value) = value.split_atrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_at().(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().delimiter.len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().()); |
| 439 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prefix), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value))) |
| 440 | } |
| 441 | |
| 442 | fn complete_value_candidatesrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_value_candidates().( |
| 443 | value: &OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#, |
| 444 | completer: &dyn ValueCandidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/ValueCandidates#, |
| 445 | ) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#> { |
| 446 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("complete_value_candidates: value={value:?}"); |
| 447 | |
| 448 | let mut values = completer.candidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/ValueCandidates#candidates().(); |
| 449 | values.retainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]retain().(|comp| comp.get_valuerust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]get_value().().starts_withrust-analyzer cargo clap_lex 1.0.0 ext/impl#[OsStr][OsStrExt]starts_with().(&value.to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().())); |
| 450 | values |
| 451 | } |
| 452 | |
| 453 | fn complete_candidates_strrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_candidates_str().( |
| 454 | value: &str, |
| 455 | mut values: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#>, |
| 456 | ) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#> { |
| 457 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("complete_candidates_str: value={value:?}"); |
| 458 | |
| 459 | values.retainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]retain().(|comp| comp.get_valuerust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]get_value().().starts_withrust-analyzer cargo clap_lex 1.0.0 ext/impl#[OsStr][OsStrExt]starts_with().(value)); |
| 460 | values |
| 461 | } |
| 462 | |
| 463 | fn complete_value_candidates_strrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_value_candidates_str().( |
| 464 | value: &str, |
| 465 | completer: &dyn ValueCandidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/ValueCandidates#, |
| 466 | ) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#> { |
| 467 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("complete_value_candidates_str: value={value:?}"); |
| 468 | |
| 469 | complete_candidates_strrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_candidates_str().(value, completer.candidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/ValueCandidates#candidates().()) |
| 470 | } |
| 471 | |
| 472 | fn complete_subcommandrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_subcommand().(value: &str, cmd: &claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#> { |
| 473 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!( |
| 474 | "complete_subcommand: cmd={:?}, value={:?}", |
| 475 | cmd.get_name(), |
| 476 | value |
| 477 | ); |
| 478 | |
| 479 | let mut scs: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#> = subcommandsrust-analyzer cargo clap_complete 4.6.8 engine/complete/subcommands().(cmd) |
| 480 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 481 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|x| x.get_valuerust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]get_value().().starts_withrust-analyzer cargo clap_lex 1.0.0 ext/impl#[OsStr][OsStrExt]starts_with().(value)) |
| 482 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 483 | if cmd.is_allow_external_subcommands_setrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]is_allow_external_subcommands_set().() { |
| 484 | let external_completer = cmd.getrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get().::<SubcommandCandidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/SubcommandCandidates#>(); |
| 485 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(completer) = external_completer { |
| 486 | scs.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(complete_value_candidates_strrust-analyzer cargo clap_complete 4.6.8 engine/complete/complete_value_candidates_str().( |
| 487 | value, |
| 488 | completer.value_candidatesrust-analyzer cargo clap_complete 4.6.8 engine/custom/impl#[SubcommandCandidates]value_candidates().(), |
| 489 | )); |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | scs.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().(); |
| 494 | scs.deduprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]dedup().(); |
| 495 | scs |
| 496 | } |
| 497 | |
| 498 | /// Gets all the long options, their visible aliases and flags of a [`clap::Command`] with formatted `--` prefix. |
| 499 | /// Includes `help` and `version` depending on the [`clap::Command`] settings. |
| 500 | fn longs_and_visible_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/longs_and_visible_aliases().(p: &claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#> { |
| 501 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("longs: name={}", p.get_name()); |
| 502 | |
| 503 | p.get_argumentsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_arguments().() |
| 504 | .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|a| { |
| 505 | a.get_long_and_visible_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_long_and_visible_aliases().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|longs| { |
| 506 | longs |
| 507 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 508 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| populate_arg_candidaterust-analyzer cargo clap_complete 4.6.8 engine/complete/populate_arg_candidate().(CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#::newrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]new().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("--{s}")), a)) |
| 509 | }) |
| 510 | }) |
| 511 | .flattenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flatten().() |
| 512 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 513 | } |
| 514 | |
| 515 | /// Gets all the long hidden aliases and flags of a [`clap::Command`]. |
| 516 | fn hidden_longs_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/hidden_longs_aliases().(p: &claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#> { |
| 517 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("longs: name={}", p.get_name()); |
| 518 | |
| 519 | p.get_argumentsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_arguments().() |
| 520 | .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|a| { |
| 521 | a.get_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_aliases().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|longs| { |
| 522 | longs.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| { |
| 523 | populate_arg_candidaterust-analyzer cargo clap_complete 4.6.8 engine/complete/populate_arg_candidate().(CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#::newrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]new().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("--{s}")), a).hiderust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]hide().(true) |
| 524 | }) |
| 525 | }) |
| 526 | }) |
| 527 | .flattenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flatten().() |
| 528 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 529 | } |
| 530 | |
| 531 | /// Gets all the short options, their visible aliases and flags of a [`clap::Command`]. |
| 532 | /// Includes `h` and `V` depending on the [`clap::Command`] settings. |
| 533 | fn shorts_and_visible_aliasesrust-analyzer cargo clap_complete 4.6.8 engine/complete/shorts_and_visible_aliases().(p: &claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#> { |
| 534 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("shorts: name={}", p.get_name()); |
| 535 | |
| 536 | p.get_argumentsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_arguments().() |
| 537 | .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|a| { |
| 538 | a.get_short_and_visible_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_short_and_visible_aliases().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|shorts| { |
| 539 | shorts.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| { |
| 540 | populate_arg_candidaterust-analyzer cargo clap_complete 4.6.8 engine/complete/populate_arg_candidate().(CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#::newrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]new().(s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), a).helprust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]help().( |
| 541 | a.get_helprust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_help().() |
| 542 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().() |
| 543 | .or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]or_else().(|| a.get_longrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_long().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|long| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("--{long}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())), |
| 544 | ) |
| 545 | }) |
| 546 | }) |
| 547 | }) |
| 548 | .flattenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flatten().() |
| 549 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 550 | } |
| 551 | |
| 552 | fn populate_arg_candidaterust-analyzer cargo clap_complete 4.6.8 engine/complete/populate_arg_candidate().(candidate: CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#, arg: &claprust-analyzer cargo clap 4.6.6 crate/::Argrust-analyzer cargo clap_builder 4.6.6 builder/arg/Arg#) -> CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate# { |
| 553 | candidate |
| 554 | .helprust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]help().(arg.get_helprust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_help().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().()) |
| 555 | .idrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]id().(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!!("arg::{}", arg.get_idrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_id().()))) |
| 556 | .tagrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]tag().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#( |
| 557 | arg.get_help_headingrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_help_heading().() |
| 558 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("Options") |
| 559 | .to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() |
| 560 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 561 | )) |
| 562 | .display_orderrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]display_order().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(arg.get_display_orderrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_display_order().())) |
| 563 | .hiderust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]hide().(arg.is_hide_setrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]is_hide_set().()) |
| 564 | } |
| 565 | |
| 566 | /// Get the possible values for completion |
| 567 | fn possible_valuesrust-analyzer cargo clap_complete 4.6.8 engine/complete/possible_values().( |
| 568 | a: &claprust-analyzer cargo clap 4.6.6 crate/::Argrust-analyzer cargo clap_builder 4.6.6 builder/arg/Arg#, |
| 569 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = claprust-analyzer cargo clap 4.6.6 crate/::builderrust-analyzer cargo clap_builder 4.6.6 builder/::PossibleValuerust-analyzer cargo clap_builder 4.6.6 builder/possible_value/PossibleValue#> + '_>> { |
| 570 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().a.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").takes_valuesrust-analyzer cargo clap_builder 4.6.6 builder/range/impl#[ValueRange]takes_values().() { |
| 571 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 572 | } else { |
| 573 | a.get_value_parserrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_value_parser().().possible_valuesrust-analyzer cargo clap_builder 4.6.6 builder/value_parser/impl#[ValueParser]possible_values().() |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | /// Gets subcommands of [`clap::Command`] in the form of `("name", "bin_name")`. |
| 578 | /// |
| 579 | /// Subcommand `rustup toolchain install` would be converted to |
| 580 | /// `("install", "rustup toolchain install")`. |
| 581 | fn subcommandsrust-analyzer cargo clap_complete 4.6.8 engine/complete/subcommands().(p: &claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#> { |
| 582 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("subcommands: name={}", p.get_name()); |
| 583 | debugrust-analyzer cargo clap_complete 4.6.8 macros/debug!!("subcommands: Has subcommands...{:?}", p.has_subcommands()); |
| 584 | p.get_subcommandsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_subcommands().() |
| 585 | .flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|sc| { |
| 586 | sc.get_name_and_visible_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_name_and_visible_aliases().() |
| 587 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 588 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| populate_command_candidaterust-analyzer cargo clap_complete 4.6.8 engine/complete/populate_command_candidate().(CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#::newrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]new().(s.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), p, sc)) |
| 589 | .chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(sc.get_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_aliases().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| { |
| 590 | populate_command_candidaterust-analyzer cargo clap_complete 4.6.8 engine/complete/populate_command_candidate().(CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#::newrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]new().(s.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), p, sc) |
| 591 | .hiderust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]hide().(true) |
| 592 | })) |
| 593 | }) |
| 594 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 595 | } |
| 596 | |
| 597 | fn populate_command_candidaterust-analyzer cargo clap_complete 4.6.8 engine/complete/populate_command_candidate().( |
| 598 | candidate: CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate#, |
| 599 | cmd: &claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, |
| 600 | subcommand: &claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, |
| 601 | ) -> CompletionCandidaterust-analyzer cargo clap_complete 4.6.8 engine/candidate/CompletionCandidate# { |
| 602 | candidate |
| 603 | .helprust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]help().(subcommand.get_aboutrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_about().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().()) |
| 604 | .idrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]id().(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!!("command::{}", subcommand.get_namerust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_name().()))) |
| 605 | .tagrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]tag().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#( |
| 606 | cmd.get_subcommand_help_headingrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_subcommand_help_heading().() |
| 607 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("Commands") |
| 608 | .to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() |
| 609 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 610 | )) |
| 611 | .display_orderrust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]display_order().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(subcommand.get_display_orderrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_display_order().())) |
| 612 | .hiderust-analyzer cargo clap_complete 4.6.8 engine/candidate/impl#[CompletionCandidate]hide().(subcommand.is_hide_setrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]is_hide_set().()) |
| 613 | } |
| 614 | |
| 615 | /// Parse the short flags and find the first `takes_values` option. |
| 616 | fn parse_shortflagsrust-analyzer cargo clap_complete 4.6.8 engine/complete/parse_shortflags().<'c, 's>( |
| 617 | cmd: &'c claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, |
| 618 | mut short: clap_lexrust-analyzer cargo clap_lex 1.0.0 crate/::ShortFlagsrust-analyzer cargo clap_lex 1.0.0 ShortFlags#<'s>, |
| 619 | ) -> (Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'c claprust-analyzer cargo clap 4.6.6 crate/::Argrust-analyzer cargo clap_builder 4.6.6 builder/arg/Arg#>, clap_lexrust-analyzer cargo clap_lex 1.0.0 crate/::ShortFlagsrust-analyzer cargo clap_lex 1.0.0 ShortFlags#<'s>) { |
| 620 | let takes_value_opt; |
| 621 | let mut leading_flags = 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().(); |
| 622 | // Find the first takes_values option. |
| 623 | loop { |
| 624 | match short.next_flagrust-analyzer cargo clap_lex 1.0.0 impl#[`ShortFlags<'s>`]next_flag().() { |
| 625 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(opt)) => { |
| 626 | leading_flags.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(opt); |
| 627 | let opt = cmd.get_argumentsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_arguments().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]find().(|a| { |
| 628 | let shorts = a.get_short_and_visible_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_short_and_visible_aliases().(); |
| 629 | let is_find = shorts.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| { |
| 630 | let mut iter = v.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(); |
| 631 | let c = iter.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|c| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().opt); |
| 632 | c.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() |
| 633 | }); |
| 634 | is_find.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) |
| 635 | }); |
| 636 | if opt |
| 637 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|o| 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").takes_valuesrust-analyzer cargo clap_builder 4.6.6 builder/range/impl#[ValueRange]takes_values().()) |
| 638 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) |
| 639 | { |
| 640 | takes_value_opt = opt; |
| 641 | break; |
| 642 | } |
| 643 | } |
| 644 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_)) | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 645 | takes_value_opt = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 646 | break; |
| 647 | } |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | (leading_flags, takes_value_opt, short) |
| 652 | } |
| 653 | |
| 654 | /// Parse the positional arguments. Return the new state and the new positional index. |
| 655 | fn parse_positionalrust-analyzer cargo clap_complete 4.6.8 engine/complete/parse_positional().<'a>( |
| 656 | cmd: &claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, |
| 657 | pos_index: usize, |
| 658 | is_escaped: bool, |
| 659 | state: ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#<'a>, |
| 660 | ) -> (ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#<'a>, usize) { |
| 661 | let pos_arg = cmd |
| 662 | .get_positionalsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_positionals().() |
| 663 | .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|p| p.get_indexrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_index().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pos_index)); |
| 664 | let num_args = pos_arg |
| 665 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|a| a.get_num_argsrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_num_args().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|r| r.max_valuesrust-analyzer cargo clap_builder 4.6.6 builder/range/impl#[ValueRange]max_values().())) |
| 666 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(1); |
| 667 | |
| 668 | let update_state_with_new_positional = |pos_index| -> (ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#<'a>, usize) { |
| 669 | if num_args 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 { |
| 670 | (ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Posrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Pos#((pos_index, 1)), pos_index) |
| 671 | } else { |
| 672 | if is_escaped { |
| 673 | (ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Posrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Pos#((pos_index, 1)), pos_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) |
| 674 | } else { |
| 675 | (ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::ValueDonerust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#ValueDone#, pos_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) |
| 676 | } |
| 677 | } |
| 678 | }; |
| 679 | match state { |
| 680 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::ValueDonerust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#ValueDone# => { |
| 681 | update_state_with_new_positional(pos_index) |
| 682 | }, |
| 683 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Posrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Pos#((prev_pos_index, num_arg)) => { |
| 684 | if prev_pos_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().pos_index { |
| 685 | if num_arg rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().num_args { |
| 686 | (ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Posrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Pos#((pos_index, num_arg rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1)), pos_index) |
| 687 | } else { |
| 688 | if is_escaped { |
| 689 | (ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Posrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Pos#((pos_index, 1)), pos_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) |
| 690 | } else { |
| 691 | (ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::ValueDonerust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#ValueDone#, pos_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) |
| 692 | } |
| 693 | } |
| 694 | } else { |
| 695 | update_state_with_new_positional(pos_index) |
| 696 | } |
| 697 | } |
| 698 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Optrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Opt#(..) => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!( |
| 699 | "This branch won't be hit, |
| 700 | because ParseState::Opt should not be seen as a positional argument and passed to this function." |
| 701 | ), |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | /// Parse optional flag argument. Return new state |
| 706 | fn parse_opt_valuerust-analyzer cargo clap_complete 4.6.8 engine/complete/parse_opt_value().(opt: &claprust-analyzer cargo clap 4.6.6 crate/::Argrust-analyzer cargo clap_builder 4.6.6 builder/arg/Arg#, count: usize) -> ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#<'_> { |
| 707 | let range = opt.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"); |
| 708 | let max = range.max_valuesrust-analyzer cargo clap_builder 4.6.6 builder/range/impl#[ValueRange]max_values().(); |
| 709 | if count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().max { |
| 710 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Optrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Opt#((opt, count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1)) |
| 711 | } else { |
| 712 | ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::ValueDonerust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#ValueDone# |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | fn pos_allows_hyphenrust-analyzer cargo clap_complete 4.6.8 engine/complete/pos_allows_hyphen().(cmd: &claprust-analyzer cargo clap 4.6.6 crate/::Commandrust-analyzer cargo clap_builder 4.6.6 builder/command/Command#, pos_index: usize) -> bool { |
| 717 | cmd.get_positionalsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_positionals().() |
| 718 | .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|a| a.get_indexrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_index().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pos_index)) |
| 719 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|p| p.is_allow_hyphen_values_setrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]is_allow_hyphen_values_set().()) |
| 720 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) |
| 721 | } |
| 722 | |
| 723 | fn opt_allows_hyphenrust-analyzer cargo clap_complete 4.6.8 engine/complete/opt_allows_hyphen().(state: &ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#<'_>, arg: &clap_lexrust-analyzer cargo clap_lex 1.0.0 crate/::ParsedArgrust-analyzer cargo clap_lex 1.0.0 ParsedArg#<'_>) -> bool { |
| 724 | let val = arg.to_value_osrust-analyzer cargo clap_lex 1.0.0 impl#[`ParsedArg<'s>`]to_value_os().(); |
| 725 | if val.starts_withrust-analyzer cargo clap_lex 1.0.0 ext/impl#[OsStr][OsStrExt]starts_with().("-") { |
| 726 | if let ParseStaterust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#::Optrust-analyzer cargo clap_complete 4.6.8 engine/complete/ParseState#Opt#((opt, _)) = state { |
| 727 | return opt.is_allow_hyphen_values_setrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]is_allow_hyphen_values_set().(); |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | false |
| 732 | } |