From 2b1a1742e34d281dcd49734ba84ff29d955c580b Mon Sep 17 00:00:00 2001 From: "Taylor C. Richberger" Date: Sat, 14 May 2016 18:02:39 -0600 Subject: empty group helps don't show up in help menu generation or influence indent --- Doxyfile | 2 +- args.hxx | 19 ++++++++++++------- 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 validator; public: - Group(const std::string &help, const std::function &validator = Validators::DontCare) : Base(help), validator(validator) {} - Group(Group &group, const std::string &help, const std::function &validator = Validators::DontCare) : Base(help), validator(validator) + Group(const std::string &help = std::string(), const std::function &validator = Validators::DontCare) : Base(help), validator(validator) {} + Group(Group &group, const std::string &help = std::string(), const std::function &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> GetChildDescriptions(const std::string &shortPrefix, const std::string &longPrefix, const std::string &shortSeparator, const std::string &longSeparator, unsigned int indent = 0) const + std::vector> 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> descriptions; for (const auto &child: children) { if (const Group *group = dynamic_cast(child)) { - // Push that group description on the back: - descriptions.emplace_back(group->help, "", indent); - std::vector> 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> 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("--"), -- cgit v1.2.1