| 247 | } |
| 248 | |
| 249 | void TZshCompletionGenerator::GenerateOptCompletion(TFormattedOutput& out, const TOpts& opts, const TOpt& opt, NComp::TCompleterManager& manager) { |
| 250 | auto& line = L; |
| 251 | |
| 252 | THashSet<TString> disableOptions; |
| 253 | if (opt.DisableCompletionForOptions_) { |
| 254 | disableOptions.insert("-"); |
| 255 | } else { |
| 256 | if (!opt.AllowMultipleCompletion_) { |
| 257 | for (auto shortName: opt.GetShortNames()) { |
| 258 | disableOptions.insert(TString("-") + shortName); |
| 259 | } |
| 260 | for (auto& longName: opt.GetLongNames()) { |
| 261 | disableOptions.insert("--" + longName); |
| 262 | } |
| 263 | } |
| 264 | for (auto disabledShortName : opt.DisableCompletionForChar_) { |
| 265 | auto disabledOpt = opts.FindCharOption(disabledShortName); |
| 266 | if (disabledOpt) { |
| 267 | for (auto shortName: disabledOpt->GetShortNames()) { |
| 268 | disableOptions.insert(TString("-") + shortName); |
| 269 | } |
| 270 | for (auto& longName: disabledOpt->GetLongNames()) { |
| 271 | disableOptions.insert("--" + longName); |
| 272 | } |
| 273 | } else { |
| 274 | disableOptions.insert(TString("-") + disabledShortName); |
| 275 | } |
| 276 | } |
| 277 | for (auto& disabledLongName : opt.DisableCompletionForLongName_) { |
| 278 | auto disabledOpt = opts.FindLongOption(disabledLongName); |
| 279 | if (disabledOpt) { |
| 280 | for (auto shortName: disabledOpt->GetShortNames()) { |
| 281 | disableOptions.insert(TString("-") + shortName); |
| 282 | } |
| 283 | for (auto& longName: disabledOpt->GetLongNames()) { |
| 284 | disableOptions.insert("--" + longName); |
| 285 | } |
| 286 | } else { |
| 287 | disableOptions.insert("--" + disabledLongName); |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | if (opt.DisableCompletionForFreeArgs_) { |
| 292 | disableOptions.insert(":"); |
| 293 | disableOptions.insert("*"); |
| 294 | } else { |
| 295 | for (auto i : opt.DisableCompletionForFreeArg_) { |
| 296 | disableOptions.insert(ToString(i + 1)); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | TStringBuf sep = ""; |
| 301 | |
| 302 | if (!disableOptions.empty()) { |
| 303 | line << "'("; |
| 304 | for (auto& disableOption : disableOptions) { |
| 305 | line << sep << disableOption; |
| 306 | sep = " "; |
nothing calls this directly
no test coverage detected