|
3 | 3 | #include <cucumber-cpp/internal/connectors/wire/WireServer.hpp>
|
4 | 4 | #include <cucumber-cpp/internal/connectors/wire/WireProtocol.hpp>
|
5 | 5 | #include <iostream>
|
6 |
| -#include <boost/program_options.hpp> |
7 | 6 | #include <memory>
|
| 7 | +#include <tclap/CmdLine.h> |
8 | 8 |
|
9 | 9 | namespace {
|
10 | 10 |
|
@@ -43,58 +43,45 @@ void acceptWireProtocol(
|
43 | 43 | }
|
44 | 44 |
|
45 | 45 | int CUCUMBER_CPP_EXPORT main(int argc, char** argv) {
|
46 |
| - using boost::program_options::value; |
47 |
| - boost::program_options::options_description optionDescription("Allowed options"); |
48 |
| - optionDescription.add_options()("help,h", "help for cucumber-cpp")( |
49 |
| - "verbose,v", "verbose output" |
50 |
| - )("version", "version of cucumber-cpp" |
51 |
| - )("listen,l", value<std::string>(), "listening address of wireserver" |
52 |
| - )("port,p", |
53 |
| - value<int>(), |
54 |
| - "listening port of wireserver, use '0' (zero) to select an ephemeral port") |
55 |
| -#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) |
56 |
| - ("unix,u", |
57 |
| - value<std::string>(), |
58 |
| - "listening unix socket of wireserver (disables listening on port)") |
59 |
| -#endif |
60 |
| - ; |
61 |
| - boost::program_options::variables_map optionVariableMap; |
62 |
| - boost::program_options::store( |
63 |
| - boost::program_options::parse_command_line(argc, argv, optionDescription), optionVariableMap |
64 |
| - ); |
65 |
| - boost::program_options::notify(optionVariableMap); |
66 |
| - |
67 |
| - if (optionVariableMap.count("help")) { |
68 |
| - std::cerr << optionDescription << std::endl; |
69 |
| - exit(1); |
70 |
| - } |
| 46 | + TCLAP::CmdLine cmd("C++ Cucumber wireserver", ' ', CUKE_VERSION); |
71 | 47 |
|
72 |
| - if (optionVariableMap.count("version")) { |
73 |
| - std::cout << CUKE_VERSION << std::endl; |
74 |
| - exit(0); |
75 |
| - } |
| 48 | + TCLAP::SwitchArg verboseArg("v", "verbose", "Verbose output", cmd, false); |
| 49 | + TCLAP::ValueArg<std::string> listenArg( |
| 50 | + "l", "listen", "Listening address of wireserver", false, "127.0.0.1", "string" |
| 51 | + ); |
| 52 | + cmd.add(listenArg); |
| 53 | + TCLAP::ValueArg<int> portArg( |
| 54 | + "p", |
| 55 | + "port", |
| 56 | + "Listening port of wireserver, use '0' (zero) to select an ephemeral port", |
| 57 | + false, |
| 58 | + 3902, |
| 59 | + "int" |
| 60 | + ); |
| 61 | + cmd.add(portArg); |
76 | 62 |
|
77 |
| - std::string listenHost("127.0.0.1"); |
78 |
| - if (optionVariableMap.count("listen")) { |
79 |
| - listenHost = optionVariableMap["listen"].as<std::string>(); |
80 |
| - } |
| 63 | +#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) |
| 64 | + TCLAP::ValueArg<std::string> unixArg( |
| 65 | + "u", |
| 66 | + "unix", |
| 67 | + "Listening unix socket of wireserver (disables listening on port)", |
| 68 | + false, |
| 69 | + "", |
| 70 | + "string" |
| 71 | + ); |
| 72 | + cmd.add(unixArg); |
| 73 | +#endif |
81 | 74 |
|
82 |
| - int port = 3902; |
83 |
| - if (optionVariableMap.count("port")) { |
84 |
| - port = optionVariableMap["port"].as<int>(); |
85 |
| - } |
| 75 | + cmd.parse(argc, argv); |
86 | 76 |
|
87 | 77 | std::string unixPath;
|
| 78 | + std::string listenHost = listenArg.getValue(); |
| 79 | + int port = portArg.getValue(); |
88 | 80 | #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
|
89 |
| - if (optionVariableMap.count("unix")) { |
90 |
| - unixPath = optionVariableMap["unix"].as<std::string>(); |
91 |
| - } |
| 81 | + unixPath = unixArg.getValue(); |
92 | 82 | #endif
|
93 | 83 |
|
94 |
| - bool verbose = false; |
95 |
| - if (optionVariableMap.count("verbose")) { |
96 |
| - verbose = true; |
97 |
| - } |
| 84 | + bool verbose = verboseArg.getValue(); |
98 | 85 |
|
99 | 86 | try {
|
100 | 87 | acceptWireProtocol(listenHost, port, unixPath, verbose);
|
|
0 commit comments