DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::appfwk::CommandLineInterpreter Struct Reference

CommandLineInterpreter parses the command-line options given to the application and stores the results as validated data members. More...

#include <CommandLineInterpreter.hpp>

Static Public Member Functions

static CommandLineInterpreter parse (int argc, char **argv)
 Parse the command line and return a CommandLineInterpreter struct.
 

Public Attributes

bool help_requested { false }
 
std::string app_name { "" }
 
std::string session_name { "" }
 
std::string configuration_id { "" }
 
std::string command_facility_plugin_name { "" }
 
std::string conf_service_plugin_name { "" }
 
std::vector< std::string > other_options {}
 Any other options which were passed and not recognized.
 

Detailed Description

CommandLineInterpreter parses the command-line options given to the application and stores the results as validated data members.

Please note that contrary to the rest of the framework this class is not supposed to use ERS because the ERS cannot be instantiated until the command line is parsed

Definition at line 31 of file CommandLineInterpreter.hpp.

Member Function Documentation

◆ parse()

static CommandLineInterpreter dunedaq::appfwk::CommandLineInterpreter::parse ( int argc,
char ** argv )
inlinestatic

Parse the command line and return a CommandLineInterpreter struct.

Parameters
argcNumber of arguments
argvCommand-line arguments
Returns
CommandLineInterpreter structure with parsed arguments

Definition at line 40 of file CommandLineInterpreter.hpp.

41 {
42 CommandLineInterpreter output;
43
44 std::ostringstream descstr;
45 descstr << *argv
46 << " known arguments (additional arguments will be stored and "
47 "passed on)";
48 bpo::options_description desc(descstr.str());
49 desc.add_options()("name,n", bpo::value<std::string>()->required(), "Application name")(
50 "sessionName,s", bpo::value<std::string>()->required(), "Session name")(
51 "configurationId,k", bpo::value<std::string>()->required(), "Configuration id")(
52 "commandFacility,c", bpo::value<std::string>()->required(), "CommandFacility URI")(
53 "configurationService,d", bpo::value<std::string>()->required(), "Configuration Service URI")(
54 "help,h", "produce help message");
55
56 bpo::variables_map vm;
57 auto parsed = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
58
59 output.other_options = bpo::collect_unrecognized(parsed.options, bpo::include_positional);
60 bpo::store(parsed, vm);
61
62 if (vm.count("help")) {
63 std::cout << desc << std::endl; // NOLINT
64 output.help_requested = true;
65 return output;
66 }
67
68 bpo::notify(vm);
69
70 output.app_name = vm["name"].as<std::string>();
71 output.session_name = vm["sessionName"].as<std::string>();
72 output.configuration_id = vm["configurationId"].as<std::string>();
73 output.command_facility_plugin_name = vm["commandFacility"].as<std::string>();
74 output.conf_service_plugin_name = vm["configurationService"].as<std::string>();
75 return output;
76 }

Member Data Documentation

◆ app_name

std::string dunedaq::appfwk::CommandLineInterpreter::app_name { "" }

Definition at line 80 of file CommandLineInterpreter.hpp.

80{ "" };

◆ command_facility_plugin_name

std::string dunedaq::appfwk::CommandLineInterpreter::command_facility_plugin_name { "" }

Definition at line 83 of file CommandLineInterpreter.hpp.

83{ "" };

◆ conf_service_plugin_name

std::string dunedaq::appfwk::CommandLineInterpreter::conf_service_plugin_name { "" }

Definition at line 84 of file CommandLineInterpreter.hpp.

84{ "" };

◆ configuration_id

std::string dunedaq::appfwk::CommandLineInterpreter::configuration_id { "" }

Definition at line 82 of file CommandLineInterpreter.hpp.

82{ "" };

◆ help_requested

bool dunedaq::appfwk::CommandLineInterpreter::help_requested { false }

Definition at line 78 of file CommandLineInterpreter.hpp.

78{ false };

◆ other_options

std::vector<std::string> dunedaq::appfwk::CommandLineInterpreter::other_options {}

Any other options which were passed and not recognized.

Definition at line 86 of file CommandLineInterpreter.hpp.

86{};

◆ session_name

std::string dunedaq::appfwk::CommandLineInterpreter::session_name { "" }

Definition at line 81 of file CommandLineInterpreter.hpp.

81{ "" };

The documentation for this struct was generated from the following file: