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> 19 namespace bpo = boost::program_options;
23 namespace topology_cmd
40 , m_bDisableValidation(false)
41 , m_sid(
boost::uuids::nil_uuid())
55 <<
"DDS configuration" 56 <<
" v" << USER_DEFAULTS_CFG_VERSION <<
"\n" 63 if (
nullptr == _options)
64 throw std::runtime_error(
"Internal error: options' container is empty.");
67 bpo::options_description options(
"dds-agent-cmd options");
68 options.add_options()(
"help,h",
"Produce help message");
69 options.add_options()(
"version,v",
"Version information");
70 options.add_options()(
"session,s", bpo::value<std::string>(),
"DDS Session ID");
71 options.add_options()(
"update,u",
73 "Define a topology to update currently active topology.");
74 options.add_options()(
"disable-validation",
76 "Disable topology valiadation.");
77 options.add_options()(
"activate",
79 "Request to activate agents, i.e. distribute and start user tasks.");
80 options.add_options()(
"stop",
"Request to stop execution of user tasks.");
81 options.add_options()(
"validate",
83 "Validate topology file against XSD schema.");
84 options.add_options()(
"verbose,V",
"Verbose output");
87 bpo::variables_map vm;
88 bpo::store(bpo::command_line_parser(_argc, _argv).options(options).run(), vm);
95 if (vm.count(
"help") || vm.empty())
100 if (vm.count(
"version"))
105 if (vm.count(
"session"))
106 _options->
m_sid = boost::uuids::string_generator()(vm[
"session"].as<std::string>());
107 if (vm.count(
"verbose"))
113 if (!vm.count(
"activate") && !vm.count(
"update"))
115 throw std::runtime_error(
"--disable-validation must be used together with --activate or --update");
118 if (vm.count(
"validate") && !_options->
m_sTopoFile.empty())
122 boost::filesystem::path pathTopoFile(_options->
m_sTopoFile);
123 _options->
m_sTopoFile = boost::filesystem::absolute(pathTopoFile).string();
126 if (vm.count(
"update") || vm.count(
"activate"))
129 if (!boost::filesystem::exists(_options->
m_sTopoFile))
131 std::string sMsg(
"Can't find the topo file: ");
133 throw std::runtime_error(sMsg);
136 if (vm.count(
"update"))
140 else if (vm.count(
"activate"))
145 boost::filesystem::path pathTopoFile(_options->
m_sTopoFile);
146 _options->
m_sTopoFile = boost::filesystem::absolute(pathTopoFile).string();
149 else if (vm.count(
"stop"))
ETopologyCmdType m_topologyCmd
Definition: dds-topology/src/Options.h:45
struct dds::topology_cmd::SOptions SOptions_t
dds-agent-cmd's container of options
boost::uuids::uuid m_sid
Definition: dds-topology/src/Options.h:49
#define LOG(severity)
Definition: Logger.h:54
SOptions()
Definition: dds-topology/src/Options.h:37
bool m_verbose
Definition: dds-topology/src/Options.h:47
bool ParseCmdLine(int _argc, char *_argv[], SOptions *_options)
Definition: dds-topology/src/Options.h:61
const LPCSTR g_cszReportBugsAddr("Report bugs/comments to fairroot@gsi.de")
Definition: dds-agent/src/AgentConnectionManager.h:18
ETopologyCmdType
Definition: dds-topology/src/Options.h:25
dds-agent-cmd's container of options
Definition: dds-topology/src/Options.h:35
void PrintVersion()
Definition: dds-topology/src/Options.h:52
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_sTopoFile
Definition: dds-topology/src/Options.h:46
bool m_bDisableValidation
Definition: dds-topology/src/Options.h:48