| 64 | } |
| 65 | |
| 66 | void GenerateZsh(TFormattedOutput& out, TCompleterManager& manager) const override { |
| 67 | // We should use '_alternative' here, but it doesn't process escape codes in group descriptions, |
| 68 | // so we dispatch alternatives ourselves. |
| 69 | |
| 70 | L << "local expl action"; |
| 71 | |
| 72 | size_t i = 0; |
| 73 | for (auto& alternative: Alternatives_) { |
| 74 | auto tag = "alt-" + ToString(++i); |
| 75 | auto action = alternative.Completer ? alternative.Completer->GenerateZshAction(manager) : TStringBuf(); |
| 76 | |
| 77 | L; |
| 78 | |
| 79 | if (action.empty()) { |
| 80 | L << "_message -e " << SS(tag) << " " << SS(alternative.Description); |
| 81 | } else if (action.StartsWith("((") && action.EndsWith("))")) { |
| 82 | L << "action=" << action.substr(1, action.size() - 2); |
| 83 | L << "_describe -t " << SS(tag) << " " << SS(alternative.Description) << " action -M 'r:|[_-]=* r:|=*'"; |
| 84 | } else if (action.StartsWith("(") && action.EndsWith(")")) { |
| 85 | L << "action=" << action << ""; |
| 86 | L << "_describe -t " << SS(tag) << " " << SS(alternative.Description) << " action -M 'r:|[_-]=* r:|=*'"; |
| 87 | } else if (action.StartsWith(' ')) { |
| 88 | L << action.substr(1); |
| 89 | } else { |
| 90 | L << "_description " << SS(tag) << " expl " << SS(alternative.Description); |
| 91 | TStringBuf word, args; |
| 92 | action.Split(' ', word, args); |
| 93 | L << word << " \"${expl[@]}\" " << args; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | private: |
| 99 | TVector<TAlternative> Alternatives_; |
nothing calls this directly
no test coverage detected