MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / FindCarByName

Method FindCarByName

src/main.cpp:375–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373 }
374
375 NFSVer FindCarByName(const std::string &car_name) {
376 std::vector<NFSVer> possibleNFS;
377 NFSVer carNFSVersion;
378
379 for (auto nfs : installedNFS) {
380 for (const auto &car : nfs.cars) {
381 if (car == car_name) {
382 possibleNFS.emplace_back(nfs.tag);
383 }
384 }
385 }
386
387 ASSERT(possibleNFS.size(), "Specified car '" << car_name << "' does not exist across any NFS.");
388
389 if (possibleNFS.size() == 1) {
390 carNFSVersion = possibleNFS[0];
391 } else {
392 LOG(INFO) << "Selected car exists in multiple NFS versions. Please select desired version: ";
393 for (uint8_t nfs_Idx = 0; nfs_Idx < possibleNFS.size(); ++nfs_Idx) {
394 LOG(INFO) << (int) nfs_Idx << ". " << ToString(possibleNFS[nfs_Idx]);
395 }
396 std::string line;
397 int choice = 0;
398 while ((std::cin >> choice)&&!(choice >= 0 && choice < possibleNFS.size())) {
399 LOG(INFO) << "Invalid selection, try again.";
400 }
401 carNFSVersion = possibleNFS[choice];
402 }
403 return carNFSVersion;
404 }
405};
406
407int main(int argc, char **argv) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected