| 32 | } // namespace |
| 33 | |
| 34 | int main(int argc, char** argv) { |
| 35 | colmap::InitializeGlog(argv); |
| 36 | FLAGS_alsologtostderr = true; |
| 37 | |
| 38 | std::vector<std::pair<std::string, command_func_t>> commands; |
| 39 | commands.emplace_back("mapper", &glomap::RunMapper); |
| 40 | commands.emplace_back("mapper_resume", &glomap::RunMapperResume); |
| 41 | |
| 42 | if (argc == 1) { |
| 43 | return ShowHelp(commands); |
| 44 | } |
| 45 | |
| 46 | const std::string command = argv[1]; |
| 47 | if (command == "help" || command == "-h" || command == "--help") { |
| 48 | return ShowHelp(commands); |
| 49 | } else { |
| 50 | command_func_t matched_command_func = nullptr; |
| 51 | for (const auto& command_func : commands) { |
| 52 | if (command == command_func.first) { |
| 53 | matched_command_func = command_func.second; |
| 54 | break; |
| 55 | } |
| 56 | } |
| 57 | if (matched_command_func == nullptr) { |
| 58 | std::cout << "Command " << command << " not recognized. " |
| 59 | << "To list the available commands, run `colmap help`." |
| 60 | << std::endl; |
| 61 | return EXIT_FAILURE; |
| 62 | } else { |
| 63 | int command_argc = argc - 1; |
| 64 | char** command_argv = &argv[1]; |
| 65 | command_argv[0] = argv[0]; |
| 66 | return matched_command_func(command_argc, command_argv); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | return ShowHelp(commands); |
| 71 | } |
nothing calls this directly
no test coverage detected