// // Created by mwo on 6/11/15. // #include "CmdLineOptions.h" namespace xmreg { /** * Take the acc and *avv[] from the main() and check and parse * all the options given */ CmdLineOptions::CmdLineOptions(int acc, const char *avv[]) { positional_options_description p; options_description desc( "openmonero, Open Monero backend service"); desc.add_options() ("help,h", value()->default_value(false) ->implicit_value(true), "produce help message") ("testnet,t", value()->default_value(false) ->implicit_value(true), "use testnet blockchain") ("stagenet,s", value()->default_value(false) ->implicit_value(true), "use stagenet blockchain") ("do-not-relay", value()->default_value(false) ->implicit_value(true), "does not relay txs to other nodes. useful " "when testing construction and submiting txs") ("port,p", value()->default_value("1984"), "default port for restbed service of Open Monero") ("config-file,c", value() ->default_value("./config/config.json"), "Config file path.") ("monero-log-level,m", value() ->default_value(1), "Monero log level 1-4, default is 1.") ("verbose,v", value() ->default_value(0), "OpenMonero log verbose level 0-4, default is 0.") ("log-file,l", value() ->default_value("./openmonero.log"), "Name and path to log file. -l \"\" to disable log file."); store(command_line_parser(acc, avv) .options(desc) .positional(p) .run(), vm); notify(vm); if (vm.count("help")) { if (vm["help"].as()) cout << desc << "\n"; } } /** * Return the value of the argument passed to the program * in wrapped around boost::optional */ template boost::optional CmdLineOptions::get_option(const string & opt_name) const { if (!vm.count(opt_name)) { return boost::none; } return vm[opt_name].as(); } // explicit instantiations of get_option template function template boost::optional CmdLineOptions::get_option(const string & opt_name) const; template boost::optional CmdLineOptions::get_option(const string & opt_name) const; template boost::optional CmdLineOptions::get_option(const string & opt_name) const; }