9 #include <boost/program_options/options_description.hpp> 10 #include <boost/program_options/parsers.hpp> 16 namespace bpo = boost::program_options;
20 namespace commander_cmd
34 ,
m_sid(boost::uuids::nil_uuid())
44 if (
"prep-session" == _name)
60 if (
nullptr == _options)
61 throw std::runtime_error(
"Internal error: options' container is empty.");
64 bpo::options_description options(
"dds-commander options");
65 options.add_options()(
"help,h",
"Produce help message");
66 options.add_options()(
"version,v",
"Version information");
67 options.add_options()(
69 bpo::value<std::string>(),
70 "The command is a name of a dds-commander command." 71 " Can be one of the following: start, stop, and prep-session.\n" 72 "For user's convenience it is allowed to call dds-commander without \"--command\" option" 73 " by just specifying the command name directly, like:\ndds-commander start or dds-commander stop.\n\n" 75 " start: \tStart dds-commander daemon\n" 76 " stop: \tStop dds-commander daemon\n" 77 " prep-session: \tPrepares a DDS session and returns new session ID\n");
78 options.add_options()(
"session,s", bpo::value<std::string>(),
"DDS Session ID");
81 bpo::positional_options_description pd;
85 bpo::variables_map vm;
86 bpo::store(bpo::command_line_parser(_argc, _argv).options(options).positional(pd).run(), vm);
89 if (vm.count(
"help") || vm.empty())
94 if (vm.count(
"version"))
101 if (vm.count(
"command"))
116 if (vm.count(
"session"))
118 _options->
m_sid = boost::uuids::string_generator()(vm[
"session"].as<std::string>());
boost::uuids::uuid m_sid
Definition: dds-commander/src/Options.h:54
SOptions()
Definition: dds-commander/src/Options.h:32
ECommands
Definition: dds-commander/src/Options.h:25
bool ParseCmdLine(int _argc, char *_argv[], SOptions *_options)
Definition: dds-commander/src/Options.h:58
#define LOG(severity)
Definition: Logger.h:34
std::string m_sRMS
Definition: dds-commander/src/Options.h:52
std::string m_sTopoFile
Definition: dds-commander/src/Options.h:51
struct dds::commander_cmd::SOptions SOptions_t
dds-commander's container of options
Miscellaneous functions and helpers are located here.
Definition: AgentConnectionManager.h:13
Definition: dds-commander/src/Options.h:29
dds-commander's container of options
Definition: dds-commander/src/Options.h:23
std::string m_sCfgFile
Definition: dds-commander/src/Options.h:53
ECommands m_Command
Definition: dds-commander/src/Options.h:50
static ECommands getCommandByName(const std::string &_name)
Definition: dds-commander/src/Options.h:38
Definition: dds-commander/src/Options.h:28
Definition: dds-commander/src/Options.h:30
Definition: dds-commander/src/Options.h:27