From 7a43ea1c2b418811b4d80286772f15dd08278174 Mon Sep 17 00:00:00 2001 From: Lemutar Date: Tue, 10 Jun 2014 14:45:41 +0200 Subject: [PATCH 1/3] add option parser for wireserver --- src/main.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 5288980e..ca779e4f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +using boost::program_options::value; namespace { @@ -18,8 +20,26 @@ void acceptWireProtocol(int port) { } int main(int argc, char **argv) { + + boost::program_options::options_description optionDescription("Allowed options"); + optionDescription.add_options() + ("help", "this help message") + ("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); From 9255936cbe69e47f492cd4dbc4f76c6fe60c52b5 Mon Sep 17 00:00:00 2001 From: Lemutar Date: Tue, 10 Jun 2014 14:47:36 +0200 Subject: [PATCH 2/3] remove old parser from wirde server --- src/main.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ca779e4f..b36d8d56 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,10 +40,6 @@ int main(int argc, char **argv) { } try { - 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; From 796b569867428aaa2654fcaafb5e5b5ef751b70f Mon Sep 17 00:00:00 2001 From: Lemutar Date: Tue, 10 Jun 2014 14:50:11 +0200 Subject: [PATCH 3/3] Update main.cpp Change help message --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b36d8d56..ff5860dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,7 +23,7 @@ int main(int argc, char **argv) { boost::program_options::options_description optionDescription("Allowed options"); optionDescription.add_options() - ("help", "this help message") + ("help", "help for cucumber-cpp") ("port", value(), "listening port of wireserver") ; boost::program_options::variables_map optionVariableMap;