| 300 | }; |
| 301 | |
| 302 | std::optional<CommandLineOptions> parseCommandLine(std::vector<std::string>&& argv) |
| 303 | { |
| 304 | auto parser = CommandLineParser(argv) |
| 305 | .registerOption("--bind", 1) |
| 306 | .registerOption("--port", "-p", 1) |
| 307 | .registerOption("-o", 1) |
| 308 | .registerOption("--help", "-h") |
| 309 | .registerOption("--version") |
| 310 | .registerOption("--intro") |
| 311 | .registerOption("--log_levels", 1) |
| 312 | .registerOption("--all", "-a") |
| 313 | .registerOption("--locomotion_path", 1); |
| 314 | |
| 315 | if (!parser.parse()) |
| 316 | { |
| 317 | Logging::error("{}", parser.getErrorMessage()); |
| 318 | return {}; |
| 319 | } |
| 320 | |
| 321 | CommandLineOptions options; |
| 322 | if (parser.hasOption("--version")) |
| 323 | { |
| 324 | options.action = CommandLineAction::version; |
| 325 | } |
| 326 | else if (parser.hasOption("--help") || parser.hasOption("-h")) |
| 327 | { |
| 328 | options.action = CommandLineAction::help; |
| 329 | } |
| 330 | else if (parser.hasOption("--intro")) |
| 331 | { |
| 332 | options.action = CommandLineAction::intro; |
| 333 | } |
| 334 | else |
| 335 | { |
| 336 | auto firstArg = parser.getArg(0); |
| 337 | if (firstArg == "host") |
| 338 | { |
| 339 | options.action = CommandLineAction::host; |
| 340 | options.path = parser.getArg(1); |
| 341 | } |
| 342 | else if (firstArg == "join") |
| 343 | { |
| 344 | options.action = CommandLineAction::join; |
| 345 | options.address = parser.getArg(1); |
| 346 | } |
| 347 | else if (firstArg == "uncompress") |
| 348 | { |
| 349 | options.action = CommandLineAction::uncompress; |
| 350 | options.path = parser.getArg(1); |
| 351 | } |
| 352 | else if (firstArg == "simulate") |
| 353 | { |
| 354 | options.action = CommandLineAction::simulate; |
| 355 | options.path = parser.getArg(1); |
| 356 | options.ticks = parser.getArg<int32_t>(2); |
| 357 | options.path2 = parser.getArg(3); |
| 358 | } |
| 359 | else if (firstArg == "compare") |
no test coverage detected