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_bDisiableValidation(false)
53 <<
"DDS configuration" 54 <<
" v" << USER_DEFAULTS_CFG_VERSION <<
"\n" 61 if (
nullptr == _options)
62 throw std::runtime_error(
"Internal error: options' container is empty.");
65 bpo::options_description options(
"dds-agent-cmd options");
66 options.add_options()(
"help,h",
"Produce help message");
67 options.add_options()(
"version,v",
"Version information");
68 options.add_options()(
"update,u",
69 bpo::value<std::string>(&_options->m_sTopoFile),
70 "Define a topology to update currently active topology.");
71 options.add_options()(
"disable-validation",
72 bpo::bool_switch(&_options->m_bDisiableValidation),
73 "Disiable topology valiadation.");
74 options.add_options()(
"activate",
75 bpo::value<std::string>(&_options->m_sTopoFile),
76 "Request to activate agents, i.e. distribute and start user tasks.");
77 options.add_options()(
"stop",
"Request to stop execution of user tasks.");
78 options.add_options()(
"validate",
79 bpo::value<std::string>(&_options->m_sTopoFile),
80 "Validate topology file against XSD schema.");
81 options.add_options()(
"verbose,V",
"Verbose output");
84 bpo::variables_map vm;
85 bpo::store(bpo::command_line_parser(_argc, _argv).options(options).run(), vm);
92 if (vm.count(
"help") || vm.empty())
97 if (vm.count(
"version"))
102 if (vm.count(
"verbose"))
104 _options->m_verbose =
true;
106 if (vm.count(
"disable-validation"))
108 if (!vm.count(
"activate") && !vm.count(
"update"))
110 throw std::runtime_error(
"--disable-validation must be used together with --activate or --update");
113 if (vm.count(
"validate") && !_options->m_sTopoFile.empty())
117 boost::filesystem::path pathTopoFile(_options->m_sTopoFile);
118 _options->m_sTopoFile = boost::filesystem::absolute(pathTopoFile).string();
121 if (vm.count(
"update") || vm.count(
"activate"))
124 if (!boost::filesystem::exists(_options->m_sTopoFile))
126 std::string sMsg(
"Can't find the topo file: ");
127 sMsg += _options->m_sTopoFile;
128 throw std::runtime_error(sMsg);
131 if (vm.count(
"update"))
135 else if (vm.count(
"activate"))
140 boost::filesystem::path pathTopoFile(_options->m_sTopoFile);
141 _options->m_sTopoFile = boost::filesystem::absolute(pathTopoFile).string();
144 else if (vm.count(
"stop"))
147 _options->m_sTopoFile =
"";
ETopologyCmdType m_topologyCmd
Definition: dds-topology/src/Options.h:44
struct dds::topology_cmd::SOptions SOptions_t
dds-agent-cmd's container of options
#define LOG(severity)
Definition: Logger.h:54
SOptions()
Definition: dds-topology/src/Options.h:37
bool m_verbose
Definition: dds-topology/src/Options.h:46
bool ParseCmdLine(int _argc, char *_argv[], SOptions *_options)
Definition: dds-topology/src/Options.h:59
const LPCSTR g_cszReportBugsAddr("Report bugs/comments to fairroot@gsi.de")
Definition: dds-agent/src/AgentConnectionManager.h:16
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:50
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:45
bool m_bDisiableValidation
Definition: dds-topology/src/Options.h:47