Merge pull request #72 from CrustyAuklet/text-pre-post

Add the option to add text before and after help output
This commit is contained in:
Pranav 2020-01-02 20:55:39 -06:00 committed by GitHub
commit f01beb872e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -800,6 +800,14 @@ public:
}
}
void add_description(std::string aDescription) {
mDescription = std::move(aDescription);
}
void add_epilog(std::string aEpilog) {
mEpilog = std::move(aEpilog);
}
/* Call parse_args_internal - which does all the work
* Then, validate the parsed arguments
* This variant is used mainly for testing
@ -864,6 +872,9 @@ public:
}
stream << "\n\n";
if(!parser.mDescription.empty())
stream << parser.mDescription << "\n\n";
if (!parser.mPositionalArguments.empty())
stream << "Positional arguments:\n";
@ -880,6 +891,9 @@ public:
stream.width(tLongestArgumentLength);
stream << mOptionalArgument;
}
if(!parser.mEpilog.empty())
stream << parser.mEpilog << "\n\n";
}
return stream;
@ -988,6 +1002,8 @@ private:
}
std::string mProgramName;
std::string mDescription;
std::string mEpilog;
std::list<Argument> mPositionalArguments;
std::list<Argument> mOptionalArguments;
std::map<std::string_view, list_iterator, std::less<>> mArgumentMap;