9 #include <boost/program_options/options_description.hpp> 10 #include <boost/program_options/parsers.hpp> 16 namespace bpo = boost::program_options;
33 if (token ==
"getlog")
36 throw bpo::invalid_option_value(token);
44 _out << found->second;
49 namespace agent_cmd_cmd
58 ,
m_sid(boost::uuids::nil_uuid())
71 if (
nullptr == _options)
72 throw std::runtime_error(
"Internal error: options' container is empty.");
75 bpo::options_description options(
"dds-agent-cmd options");
76 options.add_options()(
"help,h",
"Produce help message");
77 options.add_options()(
"version,v",
"Version information");
78 options.add_options()(
"session,s", bpo::value<std::string>(),
"DDS Session ID");
79 options.add_options()(
"verbose",
"Verbose output");
80 options.add_options()(
82 bpo::value<EAgentCmdType>(&_options->
m_agentCmd),
83 "The command is a name of a dds-agent-cmd command." 84 " Can be one of the following: getlog.\n" 85 "For user's convenience it is allowed to call dds-agent-cmd without \"--command\" option" 86 " by just specifying the command name directly, like:\ndds-agent-cmd getlog\n\n" 88 " getlog: \tRetrieve log files from worker nodes. Files will be saved in ~/.DDS/log/agents\n");
89 options.add_options()(
"all,a",
"Send command to all active agents");
91 bpo::positional_options_description positional;
92 positional.add(
"command", -1);
95 bpo::variables_map vm;
96 bpo::store(bpo::command_line_parser(_argc, _argv).options(options).positional(positional).run(), vm);
99 if (vm.count(
"help") || vm.empty())
104 if (vm.count(
"version"))
109 if (vm.count(
"verbose"))
124 if (vm.count(
"session"))
126 _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:52
EAgentCmdType
Definition: dds-agent-cmd/src/Options.h:20
bool m_sendCommandToAllAgents
Definition: dds-agent-cmd/src/Options.h:62
std::istream & operator>>(std::istream &_in, EAgentCmdType &_agentCmd)
Definition: dds-agent-cmd/src/Options.h:29
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:64
#define LOG(severity)
Definition: Logger.h:34
Miscellaneous functions and helpers are located here.
Definition: AgentConnectionManager.h:13
bool ParseCmdLine(int _argc, char *_argv[], SOptions *_options)
Definition: dds-agent-cmd/src/Options.h:69
const mapAgentCmdTypeCodes_t AgentCmdTypeCodeToString
Definition: dds-agent-cmd/src/Options.h:26
EAgentCmdType m_agentCmd
Definition: dds-agent-cmd/src/Options.h:63
std::map< EAgentCmdType, std::string > mapAgentCmdTypeCodes_t
Definition: dds-agent-cmd/src/Options.h:25
std::ostream & operator<<(std::ostream &_out, EAgentCmdType &_agentCmd)
Definition: dds-agent-cmd/src/Options.h:40
SOptions()
Definition: dds-agent-cmd/src/Options.h:54
boost::uuids::uuid m_sid
Definition: dds-agent-cmd/src/Options.h:65