2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "net/config/ConfigInstance.h"
44#ifndef DOXYGEN_SHOULD_SKIP_THIS
46#include "utils/Config.h"
53#pragma GCC diagnostic push
54#pragma GCC diagnostic ignored "-Wfloat-equal"
56#if __has_warning
("-Wweak-vtables")
57#pragma GCC diagnostic ignored "-Wweak-vtables"
59#if __has_warning
("-Wcovered-switch-default")
60#pragma GCC diagnostic ignored "-Wcovered-switch-default"
62#if __has_warning
("-Wmissing-noreturn")
63#pragma GCC diagnostic ignored "-Wmissing-noreturn"
65#if __has_warning
("-Wnrvo")
66#pragma GCC diagnostic ignored "-Wnrvo"
70#include "utils/CLI11.hpp"
72#pragma GCC diagnostic pop
85 std::string(
"Configuration for ")
87 .append(
" instance '")
98 "Disable this instance")
99 ->multi_option_policy(
CLI::MultiOptionPolicy::TakeLast)
101 ->default_str(
"false")
103 ->check(
CLI::IsMember({
"true",
"false"}))
104 ->group(
instanceSc->get_formatter()->get_label(
"Persistent Options"));
125 ->add_subcommand(name, description)
127 ->configurable(
false)
128 ->allow_extras(
false)
135 ->configurable(!sectionSc->get_disabled());
137 if (!sectionSc->get_disabled()) {
146 if (req != section->get_required()) {
154 ->remove_needs(section);
177 CLI::App* resultSc =
nullptr;
179 CLI::App* sectionSc =
instanceSc->get_subcommand_no_throw(name);
180 CLI::App* parentSectionSc =
instanceSc->get_parent()->get_subcommand_no_throw(name);
182 if (sectionSc !=
nullptr && (sectionSc->count_all() > 0 || !onlyGot)) {
183 resultSc = sectionSc;
184 }
else if (recursive && parentSectionSc !=
nullptr && (parentSectionSc->count_all() > 0 || !onlyGot)) {
185 resultSc = parentSectionSc;
193 ->got_subcommand(name) ||
194 (recursive &&
instanceSc->get_parent()->got_subcommand(name));
204 ->default_str(disabled ?
"true" :
"false")
CLI::App * addSection(const std::string &name, const std::string &description, const std::string &group="Sections")
CLI::App * getSection(const std::string &name, bool onlyGot=false, bool recursive=false) const
virtual ~ConfigInstance()
void setDisabled(bool disabled=true)
void setInstanceName(const std::string &instanceName)
ConfigInstance(const std::string &instanceName, Role role)
static const std::string nameAnonymous
const std::string & getInstanceName() const
bool gotSection(const std::string &name, bool recursive=false) const
void required(CLI::App *section, bool req=true)
static bool removeInstance(CLI::App *instance)
static CLI::App * addSimpleHelp(CLI::App *app)
static void disabled(CLI::App *instance, bool disabled=true)
static CLI::App * addInstance(const std::string &name, const std::string &description, const std::string &group, bool final=false)
static CLI::App * addStandardFlags(CLI::App *app)
static void required(CLI::App *instance, bool required=true)