diff options
author | Taylor C. Richberger <Taywee@gmx.com> | 2016-05-10 16:14:33 -0600 |
---|---|---|
committer | Taylor C. Richberger <Taywee@gmx.com> | 2016-05-10 16:14:33 -0600 |
commit | c14e85caa034de73c7b210b2ed265e6c9bb8f7af (patch) | |
tree | dfb29399baf4fdba28095fd5f1c48da739592155 /args.hxx | |
parent | make terminator showing optional (diff) | |
download | args.hxx-c14e85caa034de73c7b210b2ed265e6c9bb8f7af.tar.xz |
improve help generation3.0.4
Diffstat (limited to 'args.hxx')
-rw-r--r-- | args.hxx | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -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<std::string> proglines(Wrap(prognameline.str(), helpParams.width - (helpParams.progindent + 4), helpParams.width - helpParams.progindent)); auto progit = std::begin(proglines); |