SNode.C
Loading...
Searching...
No Matches
utils::SubCommand Class Reference

#include <SubCommand.h>

Inheritance diagram for utils::SubCommand:
Collaboration diagram for utils::SubCommand:

Public Member Functions

 SubCommand (const SubCommand &)=delete
 SubCommand (SubCommand &&)=delete
SubCommandoperator= (const SubCommand &)=delete
SubCommandoperator= (SubCommand &&)=delete
virtual ~SubCommand ()
std::string getName () const
std::string version () const
void parse (int argc, char *argv[])
CLI::Option * setConfig (const std::string &defaultConfigFile) const
CLI::Option * setLogFile (const std::string &defaultLogFile) const
CLI::Option * setVersionFlag (const std::string &version) const
bool hasParent () const
SubCommandgetParent ()
SubCommandallowExtras (bool allow=true)
SubCommandrequired (bool required=true, bool force=true)
SubCommandrequired (SubCommand *subCommand, bool required=true)
SubCommandrequired (CLI::Option *option, bool required=true)
SubCommandneeds (SubCommand *subCommand, bool needs=true)
SubCommanddisabled (SubCommand *subCommand, bool disabled=true)
SubCommandsetRequireCallback (const std::function< void(void)> &callback)
SubCommandfinalCallback (const std::function< void()> &finalCallback)
std::string configToStr () const
std::string help (const CLI::App *helpApp, const CLI::AppFormatMode &mode) const
template<typename NewSubCommand, typename... Args>
NewSubCommand * newSubCommand (Args &&... args)
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand ()
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand () const
CLI::Option * getOption (const std::string &name) const
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOptionVariable (const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, const CLI::Validator &additionalValidator) const
template<typename ValueTypeT>
CLI::Option * addOptionVariable (const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &additionalValidator) const
CLI::Option * addOptionFunction (const std::string &name, std::function< void(const std::string &)> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOptionFunction (const std::string &name, std::function< void(const std::string &)> &callback, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator)
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue, const CLI::Validator &validator)

Static Public Member Functions

static CLI::App * getHelpTriggerApp ()
static CLI::App * getShowConfigTriggerApp ()
static CLI::App * getCommandlineTriggerApp ()

Static Public Attributes

static std::shared_ptr< CLI::Formatter > sectionFormatter = makeSectionFormatter()

Protected Member Functions

 SubCommand (SubCommand *parent, std::shared_ptr< utils::AppWithPtr > appWithPtr, const std::string &group, bool final)
template<typename ConcretSubCommand>
 SubCommand (SubCommand *parent, ConcretSubCommand *concretSubCommand, const std::string &group, bool final=true)
SubCommanddescription (const std::string &description)
SubCommandfooter (const std::string &footer)
template<typename ValueTypeT>
CLI::Option * setDefaultValue (CLI::Option *option, const ValueTypeT &value, bool clear=true) const
CLI::Option * setConfigurable (CLI::Option *option, bool configurable) const

Static Protected Attributes

static std::map< std::string, std::string > aliases
static CLI::App * helpTriggerApp = nullptr
static CLI::App * showConfigTriggerApp = nullptr
static CLI::App * commandlineTriggerApp = nullptr

Private Member Functions

CLI::Option * initialize (CLI::Option *option, const std::string &typeName, const CLI::Validator &validator, bool configurable) const

Private Attributes

AppWithPtrsubCommandApp
SubCommandparent
bool final
CLI::Option * helpOpt = nullptr
CLI::Option * showConfigOpt = nullptr
CLI::Option * commandlineOpt = nullptr
int requiredCount = 0

Detailed Description

Definition at line 96 of file SubCommand.h.

Constructor & Destructor Documentation

◆ SubCommand() [1/4]

utils::SubCommand::SubCommand ( SubCommand * parent,
std::shared_ptr< utils::AppWithPtr > appWithPtr,
const std::string & group,
bool final )
protected

Definition at line 57 of file SubCommand.cpp.

58 : subCommandApp(appWithPtr.get())
59 , parent(parent)
60 , final(final) {
61 if (appWithPtr != nullptr) {
62 if (parent != nullptr) {
63 parent->subCommandApp->add_subcommand(appWithPtr);
64 }
65
66 subCommandApp->group(group);
67 subCommandApp->configurable(false);
68 subCommandApp->allow_extras();
69
70 static const std::shared_ptr<CLI::HelpFormatter> helpFormatter = std::make_shared<CLI::HelpFormatter>();
71
72 helpFormatter->label("SUBCOMMAND", "INSTANCE");
73 helpFormatter->label("SUBCOMMANDS", "INSTANCES");
74 helpFormatter->label("PERSISTENT", "");
75 helpFormatter->label("Persistent Options", "Options (persistent)");
76 helpFormatter->label("Nonpersistent Options", "Options (nonpersistent)");
77 helpFormatter->label("Usage", "\nUsage");
78 helpFormatter->label("bool:{true,false}", "{true,false}");
79 helpFormatter->label(":{standard,active,complete,required}", "{standard,active,complete,required}");
80 helpFormatter->label(":{standard,exact,expanded}", "{standard,exact,expanded}");
81 helpFormatter->column_width(7);
82
83 subCommandApp->formatter(helpFormatter);
84
85 static const std::shared_ptr<CLI::Config> configFormatter = std::make_shared<CLI::ConfigFormatter>();
86
87 subCommandApp->config_formatter(configFormatter);
88
89 subCommandApp->option_defaults()->take_last()->group(subCommandApp->get_formatter()->get_label("Nonpersistent Options"));
90
91 if (!final) {
93 ->set_help_flag(
94 "--help{exact},-h{exact}",
95 [subCommandApp = this->subCommandApp](std::size_t) {
97 },
98 "Print help message and exit\n"
99 "* standard: display help for the last command processed\n"
100 "* exact: display help for the command directly preceding --help")
101 ->take_first()
102 ->check(CLI::IsMember({"standard", "exact", "expanded"}))
103 ->trigger_on_parse(),
104 false);
105 } else {
107 ->set_help_flag(
108 "--help{exact},-h{exact}",
109 [subCommandApp = this->subCommandApp](std::size_t) {
111 },
112 "Print help message and exit\n"
113 "* standard: display help for the last command processed\n"
114 "* exact: display help for the command directly preceding --help")
115 ->take_first()
116 ->check(CLI::IsMember({"standard", "exact"}))
117 ->trigger_on_parse(),
118 false);
119 }
120
122 ->add_flag_function(
123 "-s,--show-config",
124 [subCommandApp = this->subCommandApp](std::size_t) {
126 },
127 "Show current configuration and exit")
128 ->take_first()
129 ->disable_flag_override()
130 ->configurable(false)
131 ->trigger_on_parse(),
132 false);
133
135 ->add_flag_function(
136 "--command-line{standard}",
137 [subCommandApp = this->subCommandApp]([[maybe_unused]] std::int64_t count) {
139 },
140 "Print command-line\n"
141 "* standard (default): Show all non-default and required options\n"
142 "* active: Show all active options\n"
143 "* complete: Show the complete option set with default values\n"
144 "* required: Show only required options")
145 ->take_first()
146 ->check(CLI::IsMember({"standard", "active", "complete", "required"}))
147 ->trigger_on_parse(),
148 false);
149 }
150 }
static CLI::App * showConfigTriggerApp
Definition SubCommand.h:238
CLI::Option * commandlineOpt
Definition SubCommand.h:251
CLI::Option * helpOpt
Definition SubCommand.h:249
AppWithPtr * subCommandApp
Definition SubCommand.h:244
SubCommand * parent
Definition SubCommand.h:245
static CLI::App * helpTriggerApp
Definition SubCommand.h:237
CLI::Option * showConfigOpt
Definition SubCommand.h:250
static CLI::App * commandlineTriggerApp
Definition SubCommand.h:239
CLI::Option * setConfigurable(CLI::Option *option, bool configurable) const

References commandlineOpt, commandlineTriggerApp, final, helpOpt, helpTriggerApp, parent, setConfigurable(), showConfigOpt, showConfigTriggerApp, and subCommandApp.

Referenced by net::config::ConfigInstance::ConfigInstance(), and utils::ConfigRoot::ConfigRoot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SubCommand() [2/4]

template<typename ConcretSubCommand>
utils::SubCommand::SubCommand ( SubCommand * parent,
ConcretSubCommand * concretSubCommand,
const std::string & group,
bool final = true )
inlineprotected

Definition at line 257 of file SubCommand.h.

259 std::make_shared<utils::AppWithPtr>(
260 std::string(ConcretSubCommand::DESCRIPTION), std::string(ConcretSubCommand::NAME), concretSubCommand, true),
261 group,
262 final) {
263 }
SubCommand(SubCommand *parent, std::shared_ptr< utils::AppWithPtr > appWithPtr, const std::string &group, bool final)

Referenced by web::http::client::ConfigHTTP::ConfigHTTP(), and subcommand::ConfigWWW::ConfigWWW().

Here is the caller graph for this function:

◆ SubCommand() [3/4]

utils::SubCommand::SubCommand ( const SubCommand & )
delete

◆ SubCommand() [4/4]

utils::SubCommand::SubCommand ( SubCommand && )
delete

◆ ~SubCommand()

utils::SubCommand::~SubCommand ( )
virtual

Definition at line 152 of file SubCommand.cpp.

152 {
153 }

Member Function Documentation

◆ addFlag() [1/2]

CLI::Option * utils::SubCommand::addFlag ( const std::string & name,
const std::string & description,
const std::string & typeName,
const CLI::Validator & validator ) const

Definition at line 396 of file SubCommand.cpp.

399 {
400 return initialize(subCommandApp //
401 ->add_flag(name, description),
402 typeName,
403 validator,
404 !subCommandApp->get_disabled());
405 }
SubCommand * description(const std::string &description)
CLI::Option * initialize(CLI::Option *option, const std::string &typeName, const CLI::Validator &validator, bool configurable) const

References initialize(), and subCommandApp.

Referenced by addFlag(), and utils::ConfigRoot::addRootOptions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addFlag() [2/2]

template<typename ValueTypeT>
CLI::Option * utils::SubCommand::addFlag ( const std::string & name,
const std::string & description,
const std::string & typeName,
ValueTypeT defaultValue,
const CLI::Validator & validator ) const

Definition at line 328 of file SubCommand.h.

332 {
333 return setDefaultValue(addFlag(name, description, typeName, additionalValidator), defaultValue);
334 }
CLI::Option * setDefaultValue(CLI::Option *option, const ValueTypeT &value, bool clear=true) const
Definition SubCommand.h:337
CLI::Option * addFlag(const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const

References addFlag().

Referenced by utils::ConfigRoot::addRootOptions(), web::http::client::ConfigHTTP::ConfigHTTP(), net::config::ConfigPhysicalSocket::ConfigPhysicalSocket(), net::config::ConfigTls::ConfigTls(), and net::config::ConfigTlsServer::ConfigTlsServer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addFlagFunction() [1/2]

CLI::Option * utils::SubCommand::addFlagFunction ( const std::string & name,
const std::function< void()> & callback,
const std::string & description,
const std::string & typeName,
const CLI::Validator & validator )

Definition at line 407 of file SubCommand.cpp.

411 {
412 CLI::Option* opt = subCommandApp //
413 ->add_flag_function(
414 name,
415 [callback](std::int64_t) {
416 callback();
417 },
419 ->type_name(typeName)
420 ->check(validator)
421 ->take_last();
422 if (opt->get_configurable()) {
423 opt->group(subCommandApp->get_formatter()->get_label("Persistent Options"));
424 }
425
426 return opt;
427 }

References subCommandApp.

Referenced by addFlagFunction().

Here is the caller graph for this function:

◆ addFlagFunction() [2/2]

CLI::Option * utils::SubCommand::addFlagFunction ( const std::string & name,
const std::function< void()> & callback,
const std::string & description,
const std::string & typeName,
const std::string & defaultValue,
const CLI::Validator & validator )

Definition at line 429 of file SubCommand.cpp.

434 {
435 return setDefaultValue(addFlagFunction(name, callback, description, typeName, validator), defaultValue);
436 }
CLI::Option * addFlagFunction(const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator)

References addFlagFunction(), and setDefaultValue().

Referenced by utils::ConfigRoot::addRootOptions(), net::config::ConfigPhysicalSocket::addSocketOption(), net::config::ConfigInstance::ConfigInstance(), and net::config::ConfigPhysicalSocketClient::ConfigPhysicalSocketClient().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addOption() [1/2]

CLI::Option * utils::SubCommand::addOption ( const std::string & name,
const std::string & description,
const std::string & typeName,
const CLI::Validator & validator ) const

Definition at line 373 of file SubCommand.cpp.

376 {
377 return initialize(subCommandApp //
378 ->add_option(name, description),
379 typeName,
380 validator,
381 !subCommandApp->get_disabled());
382 }

References initialize(), and subCommandApp.

Referenced by addOption(), utils::ConfigRoot::addRootOptions(), web::http::client::ConfigHTTP::ConfigHTTP(), net::config::ConfigTls::ConfigTls(), net::config::ConfigTlsClient::ConfigTlsClient(), and subcommand::ConfigWWW::ConfigWWW().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addOption() [2/2]

template<typename ValueTypeT>
CLI::Option * utils::SubCommand::addOption ( const std::string & name,
const std::string & description,
const std::string & typeName,
ValueTypeT defaultValue,
const CLI::Validator & validator ) const

Definition at line 289 of file SubCommand.h.

293 {
294 return setDefaultValue(addOption(name, description, typeName, additionalValidator), defaultValue);
295 }
CLI::Option * addOption(const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const

References addOption().

Referenced by utils::ConfigRoot::addRootOptions(), net::config::ConfigPhysicalSocket::ConfigPhysicalSocket(), net::config::ConfigTls::ConfigTls(), and setLogFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addOptionFunction() [1/2]

CLI::Option * utils::SubCommand::addOptionFunction ( const std::string & name,
std::function< void(const std::string &)> & callback,
const std::string & description,
const std::string & typeName,
const CLI::Validator & validator ) const

Definition at line 384 of file SubCommand.cpp.

388 {
389 return initialize(subCommandApp //
390 ->add_option_function(name, callback, description),
391 typeName,
392 validator,
393 !subCommandApp->get_disabled());
394 }

References initialize(), and subCommandApp.

Referenced by addOptionFunction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addOptionFunction() [2/2]

template<typename ValueTypeT>
CLI::Option * utils::SubCommand::addOptionFunction ( const std::string & name,
std::function< void(const std::string &)> & callback,
const std::string & description,
const std::string & typeName,
ValueTypeT defaultValue,
const CLI::Validator & validator ) const

Definition at line 318 of file SubCommand.h.

323 {
324 return setDefaultValue(addOptionFunction(name, callback, description, typeName, validator), defaultValue);
325 }
CLI::Option * addOptionFunction(const std::string &name, std::function< void(const std::string &)> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const

References addOptionFunction().

Here is the call graph for this function:

◆ addOptionVariable() [1/2]

template<typename ValueTypeT>
CLI::Option * utils::SubCommand::addOptionVariable ( const std::string & name,
ValueTypeT & variable,
const std::string & description,
const std::string & typeName,
const CLI::Validator & additionalValidator ) const

Definition at line 298 of file SubCommand.h.

302 {
303 return initialize(
304 subCommandApp->add_option(name, variable, description), typeName, additionalValidator, !subCommandApp->get_disabled());
305 }

References initialize(), and subCommandApp.

Referenced by net::config::ConfigTlsServer::ConfigTlsServer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addOptionVariable() [2/2]

template<typename ValueTypeT>
CLI::Option * utils::SubCommand::addOptionVariable ( const std::string & name,
ValueTypeT & variable,
const std::string & description,
const std::string & typeName,
ValueTypeT defaultValue,
const CLI::Validator & additionalValidator ) const

Definition at line 308 of file SubCommand.h.

313 {
314 return setDefaultValue(addOptionVariable(name, variable, description, typeName, additionalValidator), defaultValue);
315 }
CLI::Option * addOptionVariable(const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, const CLI::Validator &additionalValidator) const
Definition SubCommand.h:298

◆ allowExtras()

SubCommand * utils::SubCommand::allowExtras ( bool allow = true)

Definition at line 213 of file SubCommand.cpp.

213 {
214 subCommandApp->allow_extras(allow);
215
216 return this;
217 }

References subCommandApp.

Referenced by utils::ConfigRoot::parse1().

Here is the caller graph for this function:

◆ configToStr()

std::string utils::SubCommand::configToStr ( ) const

Definition at line 342 of file SubCommand.cpp.

342 {
343 return subCommandApp->config_to_str(true, true);
344 }

References subCommandApp.

Referenced by utils::doWriteConfig().

Here is the caller graph for this function:

◆ description()

SubCommand * utils::SubCommand::description ( const std::string & description)
protected

Definition at line 167 of file SubCommand.cpp.

167 {
168 subCommandApp->description(description);
169
170 return this;
171 }

References subCommandApp.

Referenced by utils::ConfigRoot::addRootOptions(), and net::config::ConfigSection::ConfigSection().

Here is the caller graph for this function:

◆ disabled()

SubCommand * utils::SubCommand::disabled ( SubCommand * subCommand,
bool disabled = true )

Definition at line 306 of file SubCommand.cpp.

306 {
307 if (disabled) {
308 if (subCommand->subCommandApp->get_ignore_case()) {
309 needs(subCommand, false);
310 }
311
312 for (const auto& sub : subCommand->subCommandApp->get_subcommands({})) {
313 if (sub->get_ignore_case()) {
314 subCommand->subCommandApp->remove_needs(sub);
315 sub->required(false);
316 }
317 }
318 } else {
319 if (subCommand->subCommandApp->get_ignore_case()) {
320 needs(subCommand);
321 }
322
323 for (const auto& sub : subCommand->subCommandApp->get_subcommands({})) {
324 if (sub->get_ignore_case()) {
325 subCommand->subCommandApp->needs(sub);
326 sub->required();
327 }
328 }
329 }
330
331 subCommand->subCommandApp->required(disabled ? false : subCommand->subCommandApp->get_ignore_case());
332
333 return this;
334 }
SubCommand * disabled(SubCommand *subCommand, bool disabled=true)
SubCommand * needs(SubCommand *subCommand, bool needs=true)

References needs(), and subCommandApp.

Referenced by net::config::ConfigInstance::ConfigInstance(), and net::config::ConfigInstance::setDisabled().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finalCallback()

SubCommand * utils::SubCommand::finalCallback ( const std::function< void()> & finalCallback)

Definition at line 336 of file SubCommand.cpp.

336 {
337 subCommandApp->final_callback(finalCallback);
338
339 return this;
340 }
SubCommand * finalCallback(const std::function< void()> &finalCallback)

References subCommandApp.

Referenced by utils::ConfigRoot::bootstrap(), and net::config::ConfigTlsServer::ConfigTlsServer().

Here is the caller graph for this function:

◆ footer()

SubCommand * utils::SubCommand::footer ( const std::string & footer)
protected

Definition at line 173 of file SubCommand.cpp.

173 {
174 subCommandApp->footer(footer);
175
176 return this;
177 }
SubCommand * footer(const std::string &footer)

References subCommandApp.

Referenced by utils::ConfigRoot::addRootOptions().

Here is the caller graph for this function:

◆ getCommandlineTriggerApp()

CLI::App * utils::SubCommand::getCommandlineTriggerApp ( )
static

Definition at line 219 of file SubCommand.cpp.

219 {
221 }

References commandlineTriggerApp.

◆ getHelpTriggerApp()

CLI::App * utils::SubCommand::getHelpTriggerApp ( )
static

Definition at line 227 of file SubCommand.cpp.

227 {
228 return helpTriggerApp;
229 }

References helpTriggerApp.

◆ getName()

std::string utils::SubCommand::getName ( ) const

Definition at line 155 of file SubCommand.cpp.

155 {
156 return subCommandApp->get_name();
157 }

References subCommandApp.

Referenced by net::config::ConfigTlsServer::ConfigTlsServer().

Here is the caller graph for this function:

◆ getOption()

CLI::Option * utils::SubCommand::getOption ( const std::string & name) const

Definition at line 369 of file SubCommand.cpp.

369 {
370 return subCommandApp->get_option_no_throw(name);
371 }

References subCommandApp.

Referenced by net::config::ConfigPhysicalSocket::addSocketOption(), utils::doWriteConfig(), utils::getHelp(), and utils::ConfigRoot::parse2().

Here is the caller graph for this function:

◆ getParent()

SubCommand * utils::SubCommand::getParent ( )

Definition at line 203 of file SubCommand.cpp.

203 {
204 return parent;
205 }

References parent.

Referenced by net::config::ConfigTlsServer::ConfigTlsServer(), and required().

Here is the caller graph for this function:

◆ getShowConfigTriggerApp()

CLI::App * utils::SubCommand::getShowConfigTriggerApp ( )
static

Definition at line 223 of file SubCommand.cpp.

223 {
225 }

References showConfigTriggerApp.

◆ getSubCommand() [1/2]

template<typename RequestedSubCommand>
RequestedSubCommand * utils::SubCommand::getSubCommand ( )

Definition at line 271 of file SubCommand.h.

271 {
272 auto* appWithPtr = subCommandApp->get_subcommand_no_throw(std::string(RequestedSubCommand::NAME));
273
274 AppWithPtr* subCommandApp = dynamic_cast<utils::AppWithPtr*>(appWithPtr);
275
276 return subCommandApp != nullptr ? dynamic_cast<RequestedSubCommand*>(subCommandApp->getPtr()) : nullptr;
277 }

References utils::AppWithPtr::getPtr(), and subCommandApp.

Referenced by web::http::client::SocketContextFactory::create(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSubCommand() [2/2]

template<typename RequestedSubCommand>
RequestedSubCommand * utils::SubCommand::getSubCommand ( ) const

Definition at line 280 of file SubCommand.h.

280 {
281 auto* appWithPtr = subCommandApp->get_subcommand_no_throw(std::string(RequestedSubCommand::NAME));
282
283 AppWithPtr* subCommandApp = dynamic_cast<utils::AppWithPtr*>(appWithPtr);
284
285 return subCommandApp != nullptr ? dynamic_cast<RequestedSubCommand*>(subCommandApp->getPtr()) : nullptr;
286 }

References utils::AppWithPtr::getPtr(), and subCommandApp.

Here is the call graph for this function:

◆ hasParent()

bool utils::SubCommand::hasParent ( ) const

Definition at line 199 of file SubCommand.cpp.

199 {
200 return subCommandApp->get_parent() != nullptr;
201 }

References subCommandApp.

◆ help()

std::string utils::SubCommand::help ( const CLI::App * helpApp,
const CLI::AppFormatMode & mode ) const

Definition at line 346 of file SubCommand.cpp.

346 {
347 return subCommandApp->help(helpApp, "", mode);
348 }

References subCommandApp.

Referenced by utils::getHelp().

Here is the caller graph for this function:

◆ initialize()

CLI::Option * utils::SubCommand::initialize ( CLI::Option * option,
const std::string & typeName,
const CLI::Validator & validator,
bool configurable ) const
private

Definition at line 445 of file SubCommand.cpp.

445 {
446 return setConfigurable(option, configurable) //
447 ->type_name(typeName)
448 ->check(validator);
449 }

References setConfigurable().

Referenced by addFlag(), addOption(), addOptionFunction(), and addOptionVariable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ needs()

SubCommand * utils::SubCommand::needs ( SubCommand * subCommand,
bool needs = true )

Definition at line 296 of file SubCommand.cpp.

296 {
297 if (needs) {
298 subCommandApp->needs(subCommand->subCommandApp);
299 } else {
300 subCommandApp->remove_needs(subCommand->subCommandApp);
301 }
302
303 return this;
304 }

References subCommandApp.

Referenced by disabled(), required(), and required().

Here is the caller graph for this function:

◆ newSubCommand()

template<typename NewSubCommand, typename... Args>
NewSubCommand * utils::SubCommand::newSubCommand ( Args &&... args)

Definition at line 266 of file SubCommand.h.

266 {
267 return !final ? new NewSubCommand(this, std::forward(args)...) : nullptr;
268 }

References final.

Referenced by main().

Here is the caller graph for this function:

◆ operator=() [1/2]

SubCommand & utils::SubCommand::operator= ( const SubCommand & )
delete

◆ operator=() [2/2]

SubCommand & utils::SubCommand::operator= ( SubCommand && )
delete

◆ parse()

void utils::SubCommand::parse ( int argc,
char * argv[] )

Definition at line 163 of file SubCommand.cpp.

163 {
164 subCommandApp->parse(argc, argv);
165 }

References subCommandApp.

Referenced by utils::Config::parse(), and utils::ConfigRoot::parse2().

Here is the caller graph for this function:

◆ required() [1/3]

SubCommand * utils::SubCommand::required ( bool required = true,
bool force = true )

Definition at line 231 of file SubCommand.cpp.

231 {
232 requiredCount += required ? 1 : -1;
233
234 required = force ? required : requiredCount > 0;
235
236 subCommandApp->required(required);
237
239 if (parent != nullptr) {
240 if (required) {
241 parent->needs(this);
242 }
243
244 parent->required(this, required);
245 }
246
247 return this;
248 }
SubCommand * required(bool required=true, bool force=true)
SubCommand * getParent()

References getParent(), needs(), required(), requiredCount, and subCommandApp.

Referenced by required(), and required().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ required() [2/3]

SubCommand * utils::SubCommand::required ( CLI::Option * option,
bool required = true )

Definition at line 279 of file SubCommand.cpp.

279 {
280 if (option->get_required() != required) {
281 option->required(required);
282
283 if (required) {
284 subCommandApp->needs(option);
285 option->default_str("");
286 } else {
287 subCommandApp->remove_needs(option);
288 }
289
290 this->required(required, false);
291 }
292
293 return this;
294 }

References required(), and subCommandApp.

Referenced by ConfigDb::ConfigDb(), subcommand::ConfigWWW::ConfigWWW(), ConfigDb::setHost(), and subcommand::ConfigWWW::setHtmlRoot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ required() [3/3]

SubCommand * utils::SubCommand::required ( SubCommand * subCommand,
bool required = true )

Definition at line 250 of file SubCommand.cpp.

250 {
251 if (subCommandApp->get_required() != required) {
252 if (required) {
253 needs(subCommand);
254
255 for (const auto& sub : subCommand->subCommandApp->get_subcommands([](const CLI::App* sc) -> bool {
256 return sc->get_required();
257 })) {
258 subCommand->subCommandApp->needs(sub);
259 }
260 } else {
261 needs(subCommand, false);
262
263 for (const auto& sub : subCommand->subCommandApp->get_subcommands([](const CLI::App* sc) -> bool {
264 return sc->get_required();
265 })) {
266 subCommand->subCommandApp->remove_needs(sub);
267 }
268 }
269
270 this->required(required, false);
271
272 subCommand->subCommandApp->required(required);
273 subCommand->subCommandApp->ignore_case(required);
274 }
275
276 return this;
277 }

References needs(), required(), and subCommandApp.

Referenced by required().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setConfig()

CLI::Option * utils::SubCommand::setConfig ( const std::string & defaultConfigFile) const

Definition at line 179 of file SubCommand.cpp.

179 {
180 return subCommandApp
181 ->set_config( //
182 "-c,--config-file",
183 defaultConfigFile,
184 "Read a config file",
185 false) //
186 ->take_all()
187 ->type_name("configfile")
188 ->check(!CLI::ExistingDirectory);
189 }

References subCommandApp.

Referenced by utils::ConfigRoot::addRootOptions().

Here is the caller graph for this function:

◆ setConfigurable()

CLI::Option * utils::SubCommand::setConfigurable ( CLI::Option * option,
bool configurable ) const
protected

Definition at line 438 of file SubCommand.cpp.

438 {
439 return option //
440 ->configurable(configurable)
441 ->group(subCommandApp->get_formatter()->get_label(configurable ? "Persistent Options" : "Nonpersistent Options"));
442 }

References subCommandApp.

Referenced by utils::ConfigRoot::addRootOptions(), ConfigDb::ConfigDb(), net::config::ConfigInstance::ConfigInstance(), net::config::ConfigInstance::configurable(), initialize(), and SubCommand().

Here is the caller graph for this function:

◆ setDefaultValue()

template<typename ValueTypeT>
CLI::Option * utils::SubCommand::setDefaultValue ( CLI::Option * option,
const ValueTypeT & value,
bool clear = true ) const
protected

Definition at line 337 of file SubCommand.h.

337 {
338 try {
339 option->default_val(value);
340
341 if (clear) {
342 option->clear();
343 }
344 } catch (const CLI::ParseError&) {
345 option = nullptr;
346 }
347
348 return option;
349 }

Referenced by addFlagFunction(), net::in6::stream::config::ConfigSocketClient::ConfigSocketClient(), net::in::stream::config::ConfigSocketClient::ConfigSocketClient(), net::in6::stream::config::ConfigSocketServer::ConfigSocketServer(), net::in::stream::config::ConfigSocketServer::ConfigSocketServer(), net::config::ConfigPhysicalSocketServer::setAcceptsPerTick(), net::config::ConfigPhysicalSocketServer::setAcceptTimeout(), net::config::ConfigPhysicalSocketServer::setBacklog(), net::config::ConfigTls::setCaCert(), net::config::ConfigTls::setCaCertAcceptUnknown(), net::config::ConfigTls::setCaCertDir(), net::config::ConfigTls::setCaCertUseDefaultDir(), net::config::ConfigTls::setCert(), net::config::ConfigTls::setCertKey(), net::config::ConfigTls::setCertKeyPassword(), net::config::ConfigTls::setCipherList(), net::config::ConfigPhysicalSocketClient::setConnectTimeout(), net::config::ConfigInstance::setDisabled(), net::in6::stream::config::ConfigSocketClient::setDisableNagleAlgorithm(), net::in6::stream::config::ConfigSocketServer::setDisableNagleAlgorithm(), net::in::stream::config::ConfigSocketClient::setDisableNagleAlgorithm(), net::in::stream::config::ConfigSocketServer::setDisableNagleAlgorithm(), net::config::ConfigTlsServer::setForceSni(), web::http::client::ConfigHTTP::setHostHeader(), subcommand::ConfigWWW::setHtmlRoot(), net::config::ConfigTls::setInitTimeout(), net::in6::stream::config::ConfigSocketServer::setIPv6Only(), web::http::client::ConfigHTTP::setPipelinedRequests(), net::config::ConfigConnection::setReadBlockSize(), net::config::ConfigConnection::setReadTimeout(), net::config::ConfigPhysicalSocketClient::setReconnect(), net::config::ConfigPhysicalSocketClient::setReconnectTime(), net::config::ConfigPhysicalSocket::setRetry(), net::config::ConfigPhysicalSocket::setRetryBase(), net::config::ConfigPhysicalSocket::setRetryJitter(), net::config::ConfigPhysicalSocket::setRetryLimit(), net::config::ConfigPhysicalSocket::setRetryOnFatal(), net::config::ConfigPhysicalSocket::setRetryTimeout(), net::config::ConfigPhysicalSocket::setRetryTries(), net::in6::stream::config::ConfigSocketServer::setReuseAddress(), net::in::stream::config::ConfigSocketServer::setReuseAddress(), net::in6::stream::config::ConfigSocketServer::setReusePort(), net::in::stream::config::ConfigSocketServer::setReusePort(), net::config::ConfigTls::setShutdownTimeout(), net::config::ConfigTlsClient::setSni(), net::config::ConfigTls::setSslOptions(), net::config::ConfigConnection::setTerminateTimeout(), net::config::ConfigConnection::setWriteBlockSize(), and net::config::ConfigConnection::setWriteTimeout().

Here is the caller graph for this function:

◆ setLogFile()

CLI::Option * utils::SubCommand::setLogFile ( const std::string & defaultLogFile) const

Definition at line 191 of file SubCommand.cpp.

191 {
192 return addOption("-l,--log-file", "Log file", "logFile", defaultLogFile, !CLI::ExistingDirectory);
193 }

References addOption().

Referenced by utils::ConfigRoot::addRootOptions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRequireCallback()

SubCommand * utils::SubCommand::setRequireCallback ( const std::function< void(void)> & callback)

Definition at line 207 of file SubCommand.cpp.

207 {
208 subCommandApp->require_callback(callback);
209
210 return this;
211 }

References subCommandApp.

◆ setVersionFlag()

CLI::Option * utils::SubCommand::setVersionFlag ( const std::string & version) const

Definition at line 195 of file SubCommand.cpp.

195 {
196 return subCommandApp->set_version_flag("-v,--version", version, "Framework version");
197 }
std::string version() const

References subCommandApp.

Referenced by utils::ConfigRoot::addRootOptions().

Here is the caller graph for this function:

◆ version()

std::string utils::SubCommand::version ( ) const

Definition at line 159 of file SubCommand.cpp.

159 {
160 return subCommandApp->version();
161 }

References subCommandApp.

Referenced by utils::ConfigRoot::parse2().

Here is the caller graph for this function:

Member Data Documentation

◆ aliases

std::map< std::string, std::string > utils::SubCommand::aliases
staticprotected

Definition at line 235 of file SubCommand.h.

Referenced by utils::ConfigRoot::parse2().

◆ commandlineOpt

CLI::Option* utils::SubCommand::commandlineOpt = nullptr
private

Definition at line 251 of file SubCommand.h.

Referenced by SubCommand().

◆ commandlineTriggerApp

CLI::App * utils::SubCommand::commandlineTriggerApp = nullptr
staticprotected

◆ final

bool utils::SubCommand::final
private

Definition at line 247 of file SubCommand.h.

Referenced by newSubCommand(), and SubCommand().

◆ helpOpt

CLI::Option* utils::SubCommand::helpOpt = nullptr
private

Definition at line 249 of file SubCommand.h.

Referenced by SubCommand().

◆ helpTriggerApp

CLI::App * utils::SubCommand::helpTriggerApp = nullptr
staticprotected

◆ parent

SubCommand* utils::SubCommand::parent
private

Definition at line 245 of file SubCommand.h.

Referenced by getParent(), and SubCommand().

◆ requiredCount

int utils::SubCommand::requiredCount = 0
private

Definition at line 253 of file SubCommand.h.

Referenced by required().

◆ sectionFormatter

std::shared_ptr< CLI::Formatter > utils::SubCommand::sectionFormatter = makeSectionFormatter()
static

Definition at line 232 of file SubCommand.h.

◆ showConfigOpt

CLI::Option* utils::SubCommand::showConfigOpt = nullptr
private

Definition at line 250 of file SubCommand.h.

Referenced by SubCommand().

◆ showConfigTriggerApp

CLI::App * utils::SubCommand::showConfigTriggerApp = nullptr
staticprotected

◆ subCommandApp


The documentation for this class was generated from the following files: