diff options
Diffstat (limited to 'client/main.cpp')
| -rw-r--r-- | client/main.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/client/main.cpp b/client/main.cpp new file mode 100644 index 0000000..fb05171 --- /dev/null +++ b/client/main.cpp @@ -0,0 +1,51 @@ + +#include "cmixclient.hpp" + +#include "uriparser.hpp" +#include "logging.hpp" + +#include <boost/program_options.hpp> + +#include <vector> +#include <iostream> + +int main(int argc, char* argv[]) { + namespace po = boost::program_options; + + init_logging(boost::log::trivial::severity_level::trace, "client"); + + BOOST_LOG_TRIVIAL(info) << "Started node"; + + po::options_description desc("Allowed options"); + desc.add_options() + ("help,h", "produce help message.") + ("network,n", po::value<std::vector<std::string>>()->multitoken(), "The addresses of the network nodes in order") + ; + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + return 0; + } + + std::vector<std::string> network; + if(vm.count("network")) { + network = vm["network"].as<std::vector<std::string>>(); + } else { + std::cerr << "network option is required." << std::endl; + return -1; + } + + std::vector<NodeDetails> node_details; + for(auto&& node : network) { + Uri uri = parse_uri(node); + + node_details.push_back({uri.host, uri.port}); + } + + CMixClient cmix_client(node_details); + cmix_client.run(); +} |
