9 #include <boost/filesystem/operations.hpp> 10 #include <boost/filesystem/path.hpp> 11 #include <boost/program_options/options_description.hpp> 12 #include <boost/program_options/parsers.hpp> 13 #include <boost/property_tree/ini_parser.hpp> 14 #include <boost/property_tree/ptree.hpp> 22 namespace bpo = boost::program_options;
37 boost::uuids::uuid
m_sid = boost::uuids::nil_uuid();
42 return _stream <<
"\nRMS: " << val.
m_sRMS <<
"\nPlug-in's configuration file: " << val.
m_sCfgFile;
48 if (
nullptr == _options)
49 throw std::runtime_error(
"Internal error: options' container is empty.");
52 bpo::options_description options(
"dds-submit options");
53 options.add_options()(
"help,h",
"Produce help message");
54 options.add_options()(
"version,v",
"Version information");
55 options.add_options()(
"session,s", bpo::value<std::string>(),
"DDS Session ID");
56 options.add_options()(
57 "list,l", bpo::bool_switch(&_options->
m_bListPlugins),
"List all available RMS plug-ins");
58 options.add_options()(
"rms,r",
59 bpo::value<std::string>(&_options->
m_sRMS),
60 "Defines a destination resource " 61 "management system plug-in. Use " 62 "\"--list\" to find out names " 63 "of available RMS plug-ins.");
64 options.add_options()(
"config,c",
65 bpo::value<std::string>(&_options->
m_sCfgFile),
66 "A plug-in's configuration file. It can be used to provide additional RMS options");
67 options.add_options()(
"path",
68 bpo::value<std::string>(&_options->
m_sPath),
69 "A plug-in's directory search path. It can be used for external RMS plug-ins.");
70 options.add_options()(
"number,n",
71 bpo::value<size_t>(&_options->
m_number)->default_value(1),
72 "Defines a number of agents to spawn." 73 "If 0 is provided as an argument, then a number of available logical cores will be " 75 options.add_options()(
76 "slots", bpo::value<size_t>(&_options->
m_slots),
"Defines a number of task slots per agent.");
79 bpo::variables_map vm;
80 bpo::store(bpo::command_line_parser(_argc, _argv).options(options).run(), vm);
88 bpo::variables_map::const_iterator found =
91 [](
const bpo::variables_map::value_type& _v) {
return (!_v.second.defaulted()); });
93 if (vm.count(
"help") || vm.end() == found)
99 if (vm.count(
"rms") && !vm.count(
"config") && !vm.count(
"number") && !vm.count(
"slots"))
105 if (vm.count(
"version"))
111 if (vm.count(
"session"))
112 _options->
m_sid = boost::uuids::string_generator()(vm[
"session"].as<std::string>());
120 boost::filesystem::path pathCfgFile(_options->
m_sCfgFile);
121 _options->
m_sCfgFile = boost::filesystem::absolute(pathCfgFile).string();
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:40
size_t m_number
Definition: dds-submit/src/Options.h:34
dds-commander's container of options
Definition: dds-submit/src/Options.h:29
#define LOG(severity)
Definition: Logger.h:34
std::string m_sRMS
Definition: dds-submit/src/Options.h:31
Miscellaneous functions and helpers are located here.
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:33
boost::uuids::uuid m_sid
Definition: dds-submit/src/Options.h:37
std::string m_sCfgFile
Definition: dds-submit/src/Options.h:32
_T & to_lower(_T &_str)
convert string to lower case.
Definition: MiscUtils.h:249
std::ostream & operator<<(std::ostream &_stream, const SOptions &val)
Definition: dds-submit/src/Options.h:40
bool m_bListPlugins
Definition: dds-submit/src/Options.h:36
size_t m_slots
Definition: dds-submit/src/Options.h:35
bool ParseCmdLine(int _argc, char *_argv[], SOptions *_options)
Definition: dds-submit/src/Options.h:46