5 #ifndef _DDS_OPTIONS_H_ 6 #define _DDS_OPTIONS_H_ 9 #include <boost/program_options/options_description.hpp> 10 #include <boost/program_options/parsers.hpp> 17 namespace bpo = boost::program_options;
35 boost::uuids::uuid
m_sid{ boost::uuids::nil_uuid() };
41 if (
nullptr == _options)
42 throw std::runtime_error(
"Internal error: options' container is empty.");
45 bpo::options_description options(
"dds-info options");
46 options.add_options()(
"help,h",
"Produce help message");
47 options.add_options()(
"version,v",
"Version information");
48 options.add_options()(
"session,s", bpo::value<std::string>(),
"DDS Session ID");
49 options.add_options()(
"commander-pid",
51 "Return the pid of the commander server");
52 options.add_options()(
53 "status", bpo::bool_switch(&_options->
m_bNeedStatus),
"Query current status of DDS commander server");
54 options.add_options()(
"agent-list,l",
56 "Show detailed info about all online agents");
57 options.add_options()(
58 "slot-list", bpo::bool_switch(&_options->
m_bNeedSlotList),
"Show detailed info about all online slots");
59 options.add_options()(
"active-count,n",
61 "Returns a number of online agents.");
62 options.add_options()(
63 "idle-count", bpo::bool_switch(&_options->
m_bNeedIdleCount),
"Returns a number of idle agents.");
64 options.add_options()(
"executing-count",
66 "Returns a number of executing agents.");
67 options.add_options()(
"wait",
69 "The command will block infinitely until a required number of agents are available. " 70 "Must be used together with --active-count, --idle-count or --executing-count");
71 options.add_options()(
"active-topology",
73 "Returns the name of the active topology");
76 bpo::variables_map vm;
77 bpo::store(bpo::command_line_parser(_argc, _argv).options(options).run(), vm);
81 auto found{ find_if(vm.begin(),
83 [](
const bpo::variables_map::value_type& _v) {
return (!_v.second.defaulted()); }) };
85 if (vm.count(
"help") || vm.end() == found)
90 if (vm.count(
"version"))
95 if (vm.count(
"session"))
96 _options->
m_sid = boost::uuids::string_generator()(vm[
"session"].as<std::string>());
108 if (vm.count(
"wait") && !needCount)
111 <<
"Option --wait must be used together with --active-count, --idle-count or --executing-count.";
125 #endif // _DDS_OPTIONS_H_ dds-info command line options
Definition: dds-info/src/Options.h:24
bool m_bNeedIdleCount
Definition: dds-info/src/Options.h:32
bool m_bNeedActiveTopology
Definition: dds-info/src/Options.h:30
bool m_bNeedAgentList
Definition: dds-info/src/Options.h:28
#define LOG(severity)
Definition: Logger.h:34
boost::uuids::uuid m_sid
Definition: dds-info/src/Options.h:35
Miscellaneous functions and helpers are located here.
Definition: AgentConnectionManager.h:13
bool m_bNeedActiveCount
Definition: dds-info/src/Options.h:31
bool m_bNeedSlotList
Definition: dds-info/src/Options.h:29
uint32_t m_nWaitCount
Definition: dds-info/src/Options.h:34
struct dds::info_cmd::SOptions SOptions_t
dds-info command line options
bool m_bNeedExecutingCount
Definition: dds-info/src/Options.h:33
bool m_bNeedStatus
Definition: dds-info/src/Options.h:27
bool m_bNeedCommanderPid
Definition: dds-info/src/Options.h:26
bool ParseCmdLine(int _argc, char *_argv[], SOptions *_options)
Definition: dds-info/src/Options.h:39