9 #include <boost/program_options/options_description.hpp> 10 #include <boost/program_options/parsers.hpp> 17 namespace bpo = boost::program_options;
36 if (token ==
"getlog")
38 else if (token ==
"update-key")
41 throw bpo::invalid_option_value(token);
47 auto found = AgentCmdTypeCodeToString.find(_agentCmd);
48 if (found != AgentCmdTypeCodeToString.end())
49 _out << found->second;
54 namespace agent_cmd_cmd
60 : m_sendCommandToAllAgents(false)
63 , m_sid(
boost::uuids::nil_uuid())
78 <<
"DDS configuration" 79 <<
" v" << USER_DEFAULTS_CFG_VERSION <<
"\n" 86 if (
nullptr == _options)
87 throw std::runtime_error(
"Internal error: options' container is empty.");
90 bpo::options_description options(
"dds-agent-cmd options");
91 options.add_options()(
"help,h",
"Produce help message");
92 options.add_options()(
"version,v",
"Version information");
93 options.add_options()(
"session,s", bpo::value<std::string>(),
"DDS Session ID");
94 options.add_options()(
"verbose",
"Verbose output");
95 options.add_options()(
97 bpo::value<EAgentCmdType>(&_options->
m_agentCmd),
98 "The command is a name of a dds-agent-cmd command." 99 " Can be one of the following: getlog, and update-key.\n" 100 "For user's convenience it is allowed to call dds-agent-cmd without \"--command\" option" 101 " by just specifying the command name directly, like:\ndds-agent-cmd getlog\n\n" 103 " getlog: \tRetrieve log files from worker nodes. Files will be saved in ~/.DDS/log/agents\n" 104 " update-key: \tIt forces an update of a given task's property in the topology. Name of the property " 106 "its value should be provided additionally (see --key and --value) \n");
107 options.add_options()(
"all,a",
"Send command to all active agents");
108 options.add_options()(
109 "key", bpo::value<std::string>(&_options->
m_sUpdKey_key),
"Specefies the key to update");
110 options.add_options()(
"value",
112 "Specefies the new value ofthe given key");
114 bpo::positional_options_description positional;
115 positional.add(
"command", -1);
118 bpo::variables_map vm;
119 bpo::store(bpo::command_line_parser(_argc, _argv).options(options).positional(positional).run(), vm);
124 if (vm.count(
"help") || vm.empty())
129 if (vm.count(
"version"))
134 if (vm.count(
"verbose"))
156 if (vm.count(
"session"))
158 _options->
m_sid = boost::uuids::string_generator()(vm[
"session"].as<std::string>());
dds-agent-cmd's container of options
Definition: dds-agent-cmd/src/Options.h:57
EAgentCmdType
Definition: dds-agent-cmd/src/Options.h:21
bool m_sendCommandToAllAgents
Definition: dds-agent-cmd/src/Options.h:67
std::istream & operator>>(std::istream &_in, EAgentCmdType &_agentCmd)
Definition: dds-agent-cmd/src/Options.h:32
struct dds::agent_cmd_cmd::SOptions SOptions_t
dds-agent-cmd's container of options
bool m_verbose
Definition: dds-agent-cmd/src/Options.h:71
#define LOG(severity)
Definition: Logger.h:54
std::string m_sUpdKey_value
Definition: dds-agent-cmd/src/Options.h:70
const LPCSTR g_cszReportBugsAddr("Report bugs/comments to fairroot@gsi.de")
Definition: dds-agent/src/AgentConnectionManager.h:18
bool ParseCmdLine(int _argc, char *_argv[], SOptions *_options)
Definition: dds-agent-cmd/src/Options.h:84
void PrintVersion()
Definition: dds-agent-cmd/src/Options.h:75
const mapAgentCmdTypeCodes_t AgentCmdTypeCodeToString
Definition: dds-agent-cmd/src/Options.h:28
void option_dependency(const boost::program_options::variables_map &_vm, const char *_for_what, const char *_required_option)
The option_dependency function used to check that if 'for_what' is specified, then 'required_option' ...
Definition: BOOSTHelper.h:85
EAgentCmdType m_agentCmd
Definition: dds-agent-cmd/src/Options.h:68
std::map< EAgentCmdType, std::string > mapAgentCmdTypeCodes_t
Definition: dds-agent-cmd/src/Options.h:27
std::ostream & operator<<(std::ostream &_out, EAgentCmdType &_agentCmd)
Definition: dds-agent-cmd/src/Options.h:45
SOptions()
Definition: dds-agent-cmd/src/Options.h:59
std::string m_sUpdKey_key
Definition: dds-agent-cmd/src/Options.h:69
boost::uuids::uuid m_sid
Definition: dds-agent-cmd/src/Options.h:72