aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor C. Richberger <Taywee@gmx.com>2016-05-14 18:02:39 -0600
committerTaylor C. Richberger <Taywee@gmx.com>2016-05-14 18:02:39 -0600
commit2b1a1742e34d281dcd49734ba84ff29d955c580b (patch)
treeee21f8feaff70d7320bc7985bd8478233560a5ce
parentfix a few readme things (diff)
downloadargs.hxx-2b1a1742e34d281dcd49734ba84ff29d955c580b.tar.xz
empty group helps don't show up in help menu generation or influence indent4.1.4
-rw-r--r--Doxyfile2
-rw-r--r--args.hxx19
2 files changed, 13 insertions, 8 deletions
diff --git a/Doxyfile b/Doxyfile
index d36814d..11391a7 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -38,7 +38,7 @@ PROJECT_NAME = "args"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 4.1.3
+PROJECT_NUMBER = 4.1.4
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/args.hxx b/args.hxx
index 17f9a3d..e0d6f54 100644
--- a/args.hxx
+++ b/args.hxx
@@ -496,8 +496,8 @@ namespace args
std::function<bool(const Group &)> validator;
public:
- Group(const std::string &help, const std::function<bool(const Group &)> &validator = Validators::DontCare) : Base(help), validator(validator) {}
- Group(Group &group, const std::string &help, const std::function<bool(const Group &)> &validator = Validators::DontCare) : Base(help), validator(validator)
+ Group(const std::string &help = std::string(), const std::function<bool(const Group &)> &validator = Validators::DontCare) : Base(help), validator(validator) {}
+ Group(Group &group, const std::string &help = std::string(), const std::function<bool(const Group &)> &validator = Validators::DontCare) : Base(help), validator(validator)
{
group.Add(*this);
}
@@ -645,16 +645,21 @@ namespace args
/** Get all the child descriptions for help generation
*/
- std::vector<std::tuple<std::string, std::string, unsigned int>> GetChildDescriptions(const std::string &shortPrefix, const std::string &longPrefix, const std::string &shortSeparator, const std::string &longSeparator, unsigned int indent = 0) const
+ std::vector<std::tuple<std::string, std::string, unsigned int>> GetChildDescriptions(const std::string &shortPrefix, const std::string &longPrefix, const std::string &shortSeparator, const std::string &longSeparator, const unsigned int indent = 0) const
{
std::vector<std::tuple<std::string, std::string, unsigned int>> descriptions;
for (const auto &child: children)
{
if (const Group *group = dynamic_cast<Group *>(child))
{
- // Push that group description on the back:
- descriptions.emplace_back(group->help, "", indent);
- std::vector<std::tuple<std::string, std::string, unsigned int>> groupDescriptions(group->GetChildDescriptions(shortPrefix, longPrefix, shortSeparator, longSeparator, indent + 1));
+ // Push that group description on the back if not empty
+ unsigned char addindent = 0;
+ if (!group->help.empty())
+ {
+ descriptions.emplace_back(group->help, "", indent);
+ addindent = 1;
+ }
+ std::vector<std::tuple<std::string, std::string, unsigned int>> groupDescriptions(group->GetChildDescriptions(shortPrefix, longPrefix, shortSeparator, longSeparator, indent + addindent));
descriptions.insert(
std::end(descriptions),
std::make_move_iterator(std::begin(groupDescriptions)),
@@ -825,7 +830,7 @@ namespace args
bool showProglinePositionals = true;
} helpParams;
ArgumentParser(const std::string &description, const std::string &epilog = std::string()) :
- Group("options", Group::Validators::AllChildGroups),
+ Group("", Group::Validators::AllChildGroups),
description(description),
epilog(epilog),
longprefix("--"),