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

Method GenerateOptsCompletion

library/cpp/getopt/small/completion_generator.cpp:175–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173 }
174
175 void TZshCompletionGenerator::GenerateOptsCompletion(TFormattedOutput& out, const TOpts& opts, NComp::TCompleterManager& manager) {
176 L << "_arguments -s \\";
177 {
178 I;
179
180 if (opts.ArgPermutation_ == EArgPermutation::REQUIRE_ORDER) {
181 L << "-S \\";
182 }
183
184 for (auto opt: opts.GetOpts()) {
185 if (!opt->Hidden_) {
186 GenerateOptCompletion(out, opts, *opt, manager);
187 }
188 }
189
190 auto argSpecs = opts.GetFreeArgSpecs();
191 size_t numFreeArgs = opts.GetFreeArgsMax();
192 bool unlimitedArgs = false;
193 if (numFreeArgs == TOpts::UNLIMITED_ARGS) {
194 numFreeArgs = argSpecs.empty() ? 0 : (argSpecs.rbegin()->first + 1);
195 unlimitedArgs = true;
196 }
197
198 for (size_t i = 0; i < numFreeArgs; ++i) {
199 auto& spec = argSpecs[i];
200 auto& line = L << "'" << (i + 1) << ":";
201 if (spec.IsOptional()) {
202 line << ":";
203 }
204 auto argHelp = spec.GetCompletionArgHelp(opts.GetDefaultFreeArgTitle());
205 if (argHelp) {
206 line << Q(argHelp);
207 } else {
208 line << " ";
209 }
210 line << ":";
211 if (spec.Completer_) {
212 line << spec.Completer_->GenerateZshAction(manager);
213 } else {
214 line << "_default";
215 }
216 line << "' \\";
217 }
218
219 if (unlimitedArgs) {
220 auto& spec = opts.GetTrailingArgSpec();
221 auto& line = L << "'*:";
222 auto argHelp = spec.GetCompletionArgHelp(opts.GetDefaultFreeArgTitle());
223 if (argHelp) {
224 line << Q(argHelp);
225 } else {
226 line << " ";
227 }
228 line << ":";
229 if (spec.Completer_) {
230 line << spec.Completer_->GenerateZshAction(manager);
231 } else {
232 line << "_default";

Callers

nothing calls this directly

Calls 10

GetOptsMethod · 0.80
GetFreeArgsMaxMethod · 0.80
GetCompletionArgHelpMethod · 0.80
IsHiddenMethod · 0.80
BClass · 0.50
emptyMethod · 0.45
rbeginMethod · 0.45
IsOptionalMethod · 0.45
GenerateZshActionMethod · 0.45
GenerateBashMethod · 0.45

Tested by

no test coverage detected