9 #include <boost/program_options/options_description.hpp> 10 #include <boost/program_options/parsers.hpp> 16 namespace bpo = boost::program_options;
35 else if (_val ==
"run")
90 if (
"stop-all" == _name)
94 if (
"set-default" == _name)
111 if (
nullptr == _options)
112 throw std::runtime_error(
"Internal error: options' container is empty.");
115 bpo::options_description options(
"dds-session options");
116 options.add_options()(
"help,h",
"Produce help message");
117 options.add_options()(
"version,v",
"Version information");
118 options.add_options()(
120 bpo::value<std::vector<std::string>>(),
121 "The command is a name of a dds-sessions command." 122 " Can be one of the following: start, stop, stop-all, list, set-default, and remove.\n\n" 123 "For user's convenience it is allowed to call dds-session without \"--command\" option" 124 " by just specifying the command name directly, like:\ndds-session start or dds-session stop.\n\n" 126 " start : \tStart a new DDS session\n" 127 " stop : \tStop a given DDS session\n" 129 " <session id>: a session ID to stop\n" 130 " stop-all : \tStop All running DDS sessions\n" 131 " list : \tList DDS sessions.\n" 133 " all: list all sessions\n" 134 " run: list only running sessions\n" 135 " set-default : \tSet a giving ID as a default DDS session\n" 137 " <session id>: a session ID to set as default\n" 138 " clean : \tRemove all STOPPED DDS sessions\n");
140 options.add_options()(
"force,f",
141 bpo::bool_switch(&_options->
m_bForce),
142 "Force commands without prompting for a confirmation.\n" 143 "Can be used only with the \"remove\" command.");
144 options.add_options()(
"mixed",
145 bpo::bool_switch(&_options->
m_bMixed),
146 "Use worker package for a mixed environment - workes on Linux and on OS X.\n" 147 "Can be used only with the \"start\" command.");
150 bpo::positional_options_description pd;
151 pd.add(
"command", 2);
154 bpo::variables_map vm;
155 bpo::store(bpo::command_line_parser(_argc, _argv).options(options).positional(pd).run(), vm);
159 bpo::variables_map::const_iterator found =
162 [](
const bpo::variables_map::value_type& _v) {
return (!_v.second.defaulted()); });
164 if (vm.count(
"help") || vm.end() == found)
169 if (vm.count(
"version"))
176 if (vm.count(
"command"))
178 std::vector<std::string> commands = vm[
"command"].as<std::vector<std::string>>();
188 if (commands.size() > 1)
193 if (commands.size() < 2)
196 <<
"Missing argument. The set-default command requares a sessions ID\n\n";
203 if (commands.size() < 2)
SSessionsSorting m_ListSessions
Definition: dds-session/src/Options.h:102
Definition: dds-session/src/Options.h:73
bool m_bMixed
Definition: dds-session/src/Options.h:105
Definition: dds-session/src/Options.h:28
SSessionsSorting(const std::string &_val)
Definition: dds-session/src/Options.h:30
Definition: dds-session/src/Options.h:71
ETypes m_typedValue
Definition: dds-session/src/Options.h:41
Definition: dds-session/src/Options.h:22
Definition: dds-session/src/Options.h:27
bool ParseCmdLine(int _argc, char *_argv[], SOptions *_options)
Definition: dds-session/src/Options.h:109
Definition: dds-session/src/Options.h:68
Definition: dds-session/src/Options.h:69
#define LOG(severity)
Definition: Logger.h:34
Definition: dds-session/src/Options.h:26
Miscellaneous functions and helpers are located here.
Definition: AgentConnectionManager.h:13
struct dds::session_cmd::SOptions SOptions_t
dds-session's container of options
std::string m_sSessionID
Definition: dds-session/src/Options.h:104
Definition: dds-session/src/Options.h:70
SOptions()
Definition: dds-session/src/Options.h:77
std::string m_value
Definition: dds-session/src/Options.h:40
ECommands m_Command
Definition: dds-session/src/Options.h:101
bool m_bForce
Definition: dds-session/src/Options.h:103
ETypes
Definition: dds-session/src/Options.h:24
static ECommands getCommandByName(const std::string &_name)
Definition: dds-session/src/Options.h:84
dds-session's container of options
Definition: dds-session/src/Options.h:64
Definition: dds-session/src/Options.h:72
Definition: dds-session/src/Options.h:74
ECommands
Definition: dds-session/src/Options.h:66