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)
76 <<
"DDS configuration" 77 <<
" v" << USER_DEFAULTS_CFG_VERSION <<
"\n" 84 if (
nullptr == _options)
85 throw std::runtime_error(
"Internal error: options' container is empty.");
88 bpo::options_description options(
"dds-agent-cmd options");
89 options.add_options()(
"help,h",
"Produce help message");
90 options.add_options()(
"version,v",
"Version information");
91 options.add_options()(
"verbose",
"Verbose output");
92 options.add_options()(
94 bpo::value<EAgentCmdType>(&_options->m_agentCmd),
95 "The command is a name of a dds-agent-cmd command." 96 " Can be one of the following: getlog, and update-key.\n" 97 "For user's convenience it is allowed to call dds-agent-cmd without \"--command\" option" 98 " by just specifying the command name directly, like:\ndds-agent-cmd getlog\n\n" 100 " getlog: \tRetrieve log files from worker nodes. Files will be saved in ~/.DDS/log/agents\n" 101 " update-key: \tIt forces an update of a given task's property in the topology. Name of the property " 103 "its value should be provided additionally (see --key and --value) \n");
104 options.add_options()(
"all,a",
"Send command to all active agents");
105 options.add_options()(
106 "key", bpo::value<std::string>(&_options->m_sUpdKey_key),
"Specefies the key to update");
107 options.add_options()(
"value",
108 bpo::value<std::string>(&_options->m_sUpdKey_value),
109 "Specefies the new value ofthe given key");
111 bpo::positional_options_description positional;
112 positional.add(
"command", -1);
115 bpo::variables_map vm;
116 bpo::store(bpo::command_line_parser(_argc, _argv).options(options).positional(positional).run(), vm);
121 if (vm.count(
"help") || vm.empty())
126 if (vm.count(
"version"))
131 if (vm.count(
"verbose"))
133 _options->m_verbose =
true;
151 _options->m_sendCommandToAllAgents =
true;
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:66
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:70
#define LOG(severity)
Definition: Logger.h:54
std::string m_sUpdKey_value
Definition: dds-agent-cmd/src/Options.h:69
const LPCSTR g_cszReportBugsAddr("Report bugs/comments to fairroot@gsi.de")
Definition: dds-agent/src/AgentConnectionManager.h:16
bool ParseCmdLine(int _argc, char *_argv[], SOptions *_options)
Definition: dds-agent-cmd/src/Options.h:82
void PrintVersion()
Definition: dds-agent-cmd/src/Options.h:73
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:67
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:68