| 430 | } |
| 431 | |
| 432 | static bool try_autocomplete(color_ostream &con, const std::string &first, std::string &completed) |
| 433 | { |
| 434 | std::vector<std::string> commands, possible; |
| 435 | |
| 436 | get_commands(con, commands); |
| 437 | for (auto &command : commands) |
| 438 | if (command.substr(0, first.size()) == first) |
| 439 | possible.push_back(command); |
| 440 | |
| 441 | if (possible.size() == 1) |
| 442 | { |
| 443 | completed = possible[0]; |
| 444 | //fprintf(stderr, "Autocompleted %s to %s\n", , ); |
| 445 | con.printerr("{} is not recognized. Did you mean {}?\n", first, completed); |
| 446 | return true; |
| 447 | } |
| 448 | |
| 449 | if (possible.size() > 1 && possible.size() < 8) |
| 450 | { |
| 451 | std::string out; |
| 452 | for (size_t i = 0; i < possible.size(); i++) |
| 453 | out += " " + possible[i]; |
| 454 | con.printerr("{} is not recognized. Possible completions:{}\n", first, out); |
| 455 | return true; |
| 456 | } |
| 457 | |
| 458 | return false; |
| 459 | } |
| 460 | |
| 461 | bool Core::addScriptPath(std::filesystem::path path, bool search_before) |
| 462 | { |
no test coverage detected