Make ArgumentParser::add_*() functions working on the parser itself chainable

This commit is contained in:
Joseph Durel 2020-07-11 10:12:57 -04:00
parent 37264dc7f8
commit aef670bd43

View File

@ -798,7 +798,8 @@ public:
// Parameter packed add_parents method // Parameter packed add_parents method
// Accepts a variadic number of ArgumentParser objects // Accepts a variadic number of ArgumentParser objects
template <typename... Targs> void add_parents(const Targs &... Fargs) { template <typename... Targs>
ArgumentParser &add_parents(const Targs &... Fargs) {
for (const ArgumentParser &tParentParser : {std::ref(Fargs)...}) { for (const ArgumentParser &tParentParser : {std::ref(Fargs)...}) {
for (auto &tArgument : tParentParser.mPositionalArguments) { for (auto &tArgument : tParentParser.mPositionalArguments) {
auto it = auto it =
@ -811,14 +812,17 @@ public:
index_argument(it); index_argument(it);
} }
} }
return *this;
} }
void add_description(std::string aDescription) { ArgumentParser &add_description(std::string aDescription) {
mDescription = std::move(aDescription); mDescription = std::move(aDescription);
return *this;
} }
void add_epilog(std::string aEpilog) { ArgumentParser &add_epilog(std::string aEpilog) {
mEpilog = std::move(aEpilog); mEpilog = std::move(aEpilog);
return *this;
} }
/* Call parse_args_internal - which does all the work /* Call parse_args_internal - which does all the work