| 34 | } |
| 35 | |
| 36 | void TZshCompletionGenerator::Generate(TStringBuf command, IOutputStream& stream) { |
| 37 | TFormattedOutput out; |
| 38 | NComp::TCompleterManager manager{command}; |
| 39 | |
| 40 | L << "#compdef " << command; |
| 41 | L; |
| 42 | L << "_" << command << "() {"; |
| 43 | { |
| 44 | I; |
| 45 | L << "local state line desc modes context curcontext=\"$curcontext\" ret=1"; |
| 46 | L << "local words_orig=(\"${words[@]}\")"; |
| 47 | L << "local current_orig=\"$((CURRENT - 1))\""; |
| 48 | L << "local prefix_orig=\"$PREFIX\""; |
| 49 | L << "local suffix_orig=\"$SUFFIX\""; |
| 50 | L; |
| 51 | std::visit(TOverloaded{ |
| 52 | [&out, &manager](const TModChooser* modChooser) { |
| 53 | GenerateModesCompletion(out, *modChooser, manager); |
| 54 | }, |
| 55 | [&out, &manager](const TOpts* opts) { |
| 56 | GenerateOptsCompletion(out, *opts, manager); |
| 57 | } |
| 58 | }, Options_); |
| 59 | L; |
| 60 | L << "return ret"; |
| 61 | } |
| 62 | L << "}"; |
| 63 | L; |
| 64 | manager.GenerateZsh(out); |
| 65 | |
| 66 | out.Print(stream); |
| 67 | } |
| 68 | |
| 69 | void TZshCompletionGenerator::GenerateModesCompletion(TFormattedOutput& out, const TModChooser& chooser, NComp::TCompleterManager& manager) { |
| 70 | auto modes = chooser.GetUnsortedModes(); |
no test coverage detected