Skip to content
Snippets Groups Projects
Commit 867f02f9 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau Committed by Volker Friese
Browse files

Improve handling of required options in histserv_nofairmq + cleanup

parent 91a7345e
No related branches found
No related tags found
1 merge request!1212Add services main folder + histogram server binary w/o FairMQ + tester binary example
......@@ -22,38 +22,34 @@ namespace cbm::services::histserv
{
// --- Define generic options
po::options_description generic("Generic options");
po::options_description generic(" Generic options");
auto generic_add = generic.add_options();
generic_add("help,h", "display this help and exit");
// --- Build default config file path
//string defconfig = std::getenv("VMCWORKDIR");
//defconfig.append("/");
//defconfig.append(DEFAULT_CONFIG);
// --- Define configuration options: Mandatory
po::options_description config_req(" Configuration (required)");
auto config_req_add = config_req.add_options();
config_req_add("input,i", po::value<string>(&fsChanHistosIn)->required()->value_name("<protocol://xxxxxx>"),
"name or host:port or whatever is needed for input channel (histos/canvases config and data), "
"cf http://api.zeromq.org/2-1:zmq-bind");
// --- Define configuration options
po::options_description config("Configuration");
// --- Define configuration options: Optional
po::options_description config(" Configuration (optional or with default)");
auto config_add = config.add_options();
config_add("input,i", po::value<string>(&fsChanHistosIn)->value_name("<protocol://xxxxxx>"),
"name or host:port or whatever is needed for input channel (histos/canvases config and data), "
" cf http://api.zeromq.org/2-1:zmq-bind");
config_add("port,p", po::value<uint32_t>(&fuHttpServerPort)->default_value(8080),
"port on which the http ROOT server (JSroot) will be available");
"port on which the http ROOT server (JSroot) will be available (mind default value!)");
config_add("output,o", po::value<string>(&fsHistoFileName)->value_name("<file name>"),
"name of the output ROOT file with histograms backup");
// config_add("config,c", po::value<string>(&fConfig)->value_name("<file name>")->default_value(defconfig),
// "name of a YAML file describing the configuration of reconstruction");
config_add("overwrite,w", po::bool_switch(&fOverwrite)->default_value(false),
"allow to overwite an existing output file");
// --- Allowed options
po::options_description cmdline_options("Allowed options");
cmdline_options.add(generic).add(config);
cmdline_options.add(generic).add(config_req).add(config);
// --- Parse command line
po::variables_map vars;
po::store(po::parse_command_line(argc, argv, cmdline_options), vars);
po::notify(vars);
// --- Help: print help information and exit program
if (vars.count("help") != 0u) {
......@@ -61,9 +57,8 @@ namespace cbm::services::histserv
exit(EXIT_SUCCESS);
}
// --- Catch mandatory parameters not being specified
if (vars.count("input") == 0u) { throw std::runtime_error("no input channel specified"); }
if (vars.count("port") == 0u) { throw std::runtime_error("no http port specified"); }
// --- Run notify after processing the help to avoid it being blocked by missing arguments
po::notify(vars);
}
// --------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment