mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 15:14:39 +00:00
Merge pull request #82 from JadeMatrix/chainable
Make ArgumentParser::add_*() functions working on the parser itself chainable
This commit is contained in:
commit
0402f2b7c3
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user