Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <cucumber-cpp/internal/connectors/wire/WireServer.hpp>
#include <cucumber-cpp/internal/connectors/wire/WireProtocol.hpp>
#include <iostream>
#include <boost/program_options.hpp>
using boost::program_options::value;

namespace {

Expand All @@ -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<int>(), "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<int>();
}

try {
int port = 3902;
if (argc > 1) {
std::string firstArg(argv[1]);
port = ::cucumber::internal::fromString<int>(firstArg);
}
acceptWireProtocol(port);
} catch (std::exception &e) {
std::cerr << e.what() << std::endl;
Expand Down