diff --git a/src/main.cpp b/src/main.cpp index 5288980e..ff5860dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +using boost::program_options::value; namespace { @@ -18,12 +20,26 @@ void acceptWireProtocol(int port) { } int main(int argc, char **argv) { + + boost::program_options::options_description optionDescription("Allowed options"); + optionDescription.add_options() + ("help", "help for cucumber-cpp") + ("port", value(), "listening port of wireserver") + ; + boost::program_options::variables_map optionVariableMap; + boost::program_options::store( boost::program_options::parse_command_line(argc, argv, optionDescription), optionVariableMap); + boost::program_options::notify(optionVariableMap); + + if (optionVariableMap.count("help")) { + std::cout << optionDescription << std::endl; + } + + int port = 3902; + if (optionVariableMap.count("port")) { + port = optionVariableMap["port"].as(); + } + try { - int port = 3902; - if (argc > 1) { - std::string firstArg(argv[1]); - port = ::cucumber::internal::fromString(firstArg); - } acceptWireProtocol(port); } catch (std::exception &e) { std::cerr << e.what() << std::endl;