9 #include <boost/program_options/options_description.hpp> 10 #include <boost/program_options/parsers.hpp> 11 #include <boost/property_tree/ptree.hpp> 14 #if BOOST_VERSION < 105900 15 #pragma clang diagnostic push 16 #pragma clang diagnostic ignored "-Wunused-local-typedef" 18 #include <boost/property_tree/ini_parser.hpp> 19 #if BOOST_VERSION < 105900 20 #pragma clang diagnostic pop 23 #include <boost/filesystem/operations.hpp> 24 #include <boost/filesystem/path.hpp> 33 namespace bpo = boost::program_options;
48 boost::uuids::uuid
m_sid = boost::uuids::nil_uuid();
53 return _stream <<
"\nRMS: " << val.
m_sRMS <<
"\nPlug-in's configuration file: " << val.
m_sCfgFile;
59 <<
"DDS configuration" 60 <<
" v" << USER_DEFAULTS_CFG_VERSION <<
"\n" 67 if (
nullptr == _options)
68 throw std::runtime_error(
"Internal error: options' container is empty.");
71 bpo::options_description options(
"dds-submit options");
72 options.add_options()(
"help,h",
"Produce help message");
73 options.add_options()(
"version,v",
"Version information");
74 options.add_options()(
"session,s", bpo::value<std::string>(),
"DDS Session ID");
75 options.add_options()(
76 "list,l", bpo::bool_switch(&_options->
m_bListPlugins),
"List all available RMS plug-ins");
77 options.add_options()(
"rms,r",
78 bpo::value<std::string>(&_options->
m_sRMS),
79 "Defines a destination resource " 80 "management system plug-in. Use " 81 "\"--list\" to find out names " 82 "of available RMS plug-ins.");
83 options.add_options()(
"config,c",
84 bpo::value<std::string>(&_options->
m_sCfgFile),
85 "A plug-in's configuration file. It can be used to provide additional RMS options");
86 options.add_options()(
"path",
87 bpo::value<std::string>(&_options->
m_sPath),
88 "A plug-in's directory search path. It can be used for external RMS plug-ins.");
89 options.add_options()(
"number,n",
90 bpo::value<size_t>(&_options->
m_number)->default_value(1),
91 "Defines a number of agents to spawn." 92 "If 0 is provided as an argument, then a number of available logical cores will be " 94 options.add_options()(
95 "slots", bpo::value<size_t>(&_options->
m_slots),
"Defines a number of task slots per agent.");
98 bpo::variables_map vm;
99 bpo::store(bpo::command_line_parser(_argc, _argv).options(options).run(), vm);
107 bpo::variables_map::const_iterator found =
108 find_if(vm.begin(), vm.end(), [](
const bpo::variables_map::value_type& _v) {
109 return (!_v.second.defaulted());
112 if (vm.count(
"help") || vm.end() == found)
118 if (vm.count(
"rms") && !vm.count(
"config") && !vm.count(
"number") && !vm.count(
"slots"))
124 if (vm.count(
"version"))
130 if (vm.count(
"session"))
131 _options->
m_sid = boost::uuids::string_generator()(vm[
"session"].as<std::string>());
139 boost::filesystem::path pathCfgFile(_options->
m_sCfgFile);
140 _options->
m_sCfgFile = boost::filesystem::absolute(pathCfgFile).string();
size_t m_number
Definition: dds-submit/src/Options.h:45
_T & to_lower(_T &_str)
convert string to lower case.
Definition: MiscUtils.h:249
dds-commander's container of options
Definition: dds-submit/src/Options.h:40
#define LOG(severity)
Definition: Logger.h:56
std::string m_sRMS
Definition: dds-submit/src/Options.h:42
void PrintVersion()
Definition: dds-submit/src/Options.h:56
const LPCSTR g_cszReportBugsAddr("Report bugs/comments to fairroot@gsi.de")
Definition: AgentConnectionManager.h:13
struct dds::submit_cmd::SOptions SOptions_t
dds-commander's container of options
std::string m_sPath
Definition: dds-submit/src/Options.h:44
boost::uuids::uuid m_sid
Definition: dds-submit/src/Options.h:48
void conflicting_options(const boost::program_options::variables_map &_vm, const char *_opt1, const char *_opt2)
The conflicting_options function used to check that 'opt1' and 'opt2' are not specified at the same t...
Definition: BOOSTHelper.h:62
std::string m_sCfgFile
Definition: dds-submit/src/Options.h:43
std::ostream & operator<<(std::ostream &_stream, const SOptions &val)
Definition: dds-submit/src/Options.h:51
bool m_bListPlugins
Definition: dds-submit/src/Options.h:47
size_t m_slots
Definition: dds-submit/src/Options.h:46
bool ParseCmdLine(int _argc, char *_argv[], SOptions *_options)
Definition: dds-submit/src/Options.h:65