| 7206 | /************************************************************************/ |
| 7207 | |
| 7208 | std::vector<std::string> |
| 7209 | GDALAlgorithm::GetAutoComplete(std::vector<std::string> &args, |
| 7210 | bool lastWordIsComplete, bool showAllOptions) |
| 7211 | { |
| 7212 | std::vector<std::string> ret; |
| 7213 | |
| 7214 | // Get inner-most algorithm |
| 7215 | std::unique_ptr<GDALAlgorithm> curAlgHolder; |
| 7216 | GDALAlgorithm *curAlg = this; |
| 7217 | while (!args.empty() && !args.front().empty() && args.front()[0] != '-') |
| 7218 | { |
| 7219 | auto subAlg = curAlg->InstantiateSubAlgorithm( |
| 7220 | args.front(), /* suggestionAllowed = */ false); |
| 7221 | if (!subAlg) |
| 7222 | break; |
| 7223 | if (args.size() == 1 && !lastWordIsComplete) |
| 7224 | { |
| 7225 | int nCount = 0; |
| 7226 | for (const auto &subAlgName : curAlg->GetSubAlgorithmNames()) |
| 7227 | { |
| 7228 | if (STARTS_WITH(subAlgName.c_str(), args.front().c_str())) |
| 7229 | nCount++; |
| 7230 | } |
| 7231 | if (nCount >= 2) |
| 7232 | { |
| 7233 | for (const std::string &subAlgName : |
| 7234 | curAlg->GetSubAlgorithmNames()) |
| 7235 | { |
| 7236 | subAlg = curAlg->InstantiateSubAlgorithm(subAlgName); |
| 7237 | if (subAlg && !subAlg->IsHidden()) |
| 7238 | ret.push_back(subAlg->GetName()); |
| 7239 | } |
| 7240 | return ret; |
| 7241 | } |
| 7242 | } |
| 7243 | showAllOptions = false; |
| 7244 | args.erase(args.begin()); |
| 7245 | curAlgHolder = std::move(subAlg); |
| 7246 | curAlg = curAlgHolder.get(); |
| 7247 | } |
| 7248 | if (curAlg != this) |
| 7249 | { |
| 7250 | curAlg->m_calledFromCommandLine = m_calledFromCommandLine; |
| 7251 | return curAlg->GetAutoComplete(args, lastWordIsComplete, |
| 7252 | /* showAllOptions = */ false); |
| 7253 | } |
| 7254 | |
| 7255 | std::string option; |
| 7256 | std::string value; |
| 7257 | ExtractLastOptionAndValue(args, option, value); |
| 7258 | |
| 7259 | if (option.empty() && !args.empty() && !args.back().empty() && |
| 7260 | args.back()[0] == '-') |
| 7261 | { |
| 7262 | const auto &lastArg = args.back(); |
| 7263 | // List available options |
| 7264 | for (const auto &arg : GetArgs()) |
| 7265 | { |
nothing calls this directly
no test coverage detected