From c14e85caa034de73c7b210b2ed265e6c9bb8f7af Mon Sep 17 00:00:00 2001 From: "Taylor C. Richberger" Date: Tue, 10 May 2016 16:14:33 -0600 Subject: improve help generation --- Doxyfile | 2 +- args.hxx | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Doxyfile b/Doxyfile index e796441..4182cbc 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 = 3.0.3 +PROJECT_NUMBER = 3.0.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 0b88924..3a60d77 100644 --- a/args.hxx +++ b/args.hxx @@ -765,6 +765,7 @@ namespace args { private: std::string prog; + std::string proglinePostfix; std::string description; std::string epilog; @@ -814,6 +815,14 @@ namespace args /** Show the terminator when both options and positional parameters are present */ bool showTerminator = true; + + /** Show the {OPTIONS} on the prog line when this is true + */ + bool showProglineOptions = true; + + /** Show the positionals on the prog line when this is true + */ + bool showProglinePositionals = true; } helpParams; ArgumentParser(const std::string &description, const std::string &epilog = std::string()) : Group("arguments", Group::Validators::AllChildGroups), @@ -837,6 +846,15 @@ namespace args void Prog(const std::string &prog) { this->prog = prog; } + /** The description that appears on the prog line after options and positionals + */ + const std::string &ProglinePostfix() const + { return proglinePostfix; } + /** The description that appears on the prog line after options and positionals + */ + void ProglinePostfix(const std::string &proglinePostfix) + { this->proglinePostfix = proglinePostfix; } + /** The description that appears above options */ const std::string &Description() const @@ -946,12 +964,22 @@ namespace args if (HasFlag()) { hasoptions = true; - prognameline << " {OPTIONS}"; + if (helpParams.showProglineOptions) + { + prognameline << " {OPTIONS}"; + } } for (const std::string &posname: GetPosNames()) { hasarguments = true; - prognameline << " [" << posname << ']'; + if (helpParams.showProglinePositionals) + { + prognameline << " [" << posname << ']'; + } + } + if (!proglinePostfix.empty()) + { + prognameline << ' ' << proglinePostfix; } const std::vector proglines(Wrap(prognameline.str(), helpParams.width - (helpParams.progindent + 4), helpParams.width - helpParams.progindent)); auto progit = std::begin(proglines); -- cgit v1.2.1