MCPcopy Create free account
hub / github.com/catboost/catboost / GenerateZsh

Method GenerateZsh

library/cpp/getopt/small/completer.cpp:66–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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_;

Callers

nothing calls this directly

Calls 8

ToStringFunction · 0.50
GenerateZshActionMethod · 0.45
emptyMethod · 0.45
StartsWithMethod · 0.45
EndsWithMethod · 0.45
substrMethod · 0.45
sizeMethod · 0.45
SplitMethod · 0.45

Tested by

no test coverage detected