| 422 | } |
| 423 | |
| 424 | void ParseCmdline(int argc, char* argv[], bool ignoreUnknown) |
| 425 | { |
| 426 | try |
| 427 | { |
| 428 | auto style = boost::program_options::command_line_style::unix_style |
| 429 | | boost::program_options::command_line_style::allow_long_disguise; |
| 430 | style &= ~ boost::program_options::command_line_style::allow_guessing; |
| 431 | if (ignoreUnknown) |
| 432 | store(command_line_parser(argc, argv).options(m_OptionsDesc).style (style).allow_unregistered().run(), m_Options); |
| 433 | else |
| 434 | store(parse_command_line(argc, argv, m_OptionsDesc, style), m_Options); |
| 435 | } |
| 436 | catch (boost::program_options::error& e) |
| 437 | { |
| 438 | ThrowFatal ("Error while parsing arguments: ", e.what()); |
| 439 | std::cerr << "args: " << e.what() << std::endl; |
| 440 | exit(EXIT_FAILURE); |
| 441 | } |
| 442 | |
| 443 | if (!ignoreUnknown && (m_Options.count("help") || m_Options.count("h"))) |
| 444 | { |
| 445 | std::cout << "i2pd version " << I2PD_VERSION << " (" << I2P_VERSION << ")" << std::endl; |
| 446 | std::cout << m_OptionsDesc; |
| 447 | exit(EXIT_SUCCESS); |
| 448 | } |
| 449 | else if (m_Options.count("version")) |
| 450 | { |
| 451 | std::cout << "i2pd version " << I2PD_VERSION << " (" << I2P_VERSION << ")" << std::endl; |
| 452 | std::cout << "Boost version " |
| 453 | << BOOST_VERSION / 100000 << "." // maj. version |
| 454 | << BOOST_VERSION / 100 % 1000 << "." // min. version |
| 455 | << BOOST_VERSION % 100 // patch version |
| 456 | << std::endl; |
| 457 | #if defined(OPENSSL_VERSION_TEXT) |
| 458 | std::cout << OPENSSL_VERSION_TEXT << std::endl; |
| 459 | #endif |
| 460 | #if defined(LIBRESSL_VERSION_TEXT) |
| 461 | std::cout << LIBRESSL_VERSION_TEXT << std::endl; |
| 462 | #endif |
| 463 | |
| 464 | exit(EXIT_SUCCESS); |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | void ParseConfig(const std::string& path) |
| 469 | { |
no test coverage detected