aboutsummaryrefslogtreecommitdiff
path: root/test.cxx
diff options
context:
space:
mode:
authorTaylor C. Richberger <Taywee@gmx.com>2016-05-06 13:29:43 -0600
committerTaylor C. Richberger <Taywee@gmx.com>2016-05-06 13:29:43 -0600
commit886ab64feff75ab3e30ac40fc0ad6eb91b8146ef (patch)
tree516f1db8e2891b85b0d40d31d0aba28dc67a0b3d /test.cxx
parentMerge branch '10-help-generator-parameters-should-be-in-a-structure' into 'ma... (diff)
downloadargs.hxx-886ab64feff75ab3e30ac40fc0ad6eb91b8146ef.tar.xz
add overloads and tests, and improve help generation in general
Diffstat (limited to 'test.cxx')
-rw-r--r--test.cxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/test.cxx b/test.cxx
index c39e000..3ad5533 100644
--- a/test.cxx
+++ b/test.cxx
@@ -245,3 +245,18 @@ TEST_CASE("Custom parser prefixes (Some Windows styles)", "[args]")
REQUIRE(input.value == "/dev/null");
REQUIRE_FALSE(output);
}
+
+TEST_CASE("Help menu can be grabbed as a string, passed into a stream, or by using the overloaded stream operator", "[args]")
+{
+ std::ostream null(nullptr);
+ args::ArgumentParser parser("This command likes to break your disks");
+ args::HelpFlag help(parser, "HELP", "Show this help menu.", args::Matcher({"help"}));
+ args::ArgFlag<long> bs(parser, "BYTES", "Block size", args::Matcher({"bs"}), 512);
+ args::ArgFlag<long> skip(parser, "BYTES", "Bytes to skip", args::Matcher({"skip"}), 0);
+ args::ArgFlag<std::string> input(parser, "BLOCK SIZE", "Block size", args::Matcher({"if"}));
+ args::ArgFlag<std::string> output(parser, "BLOCK SIZE", "Block size", args::Matcher({"of"}));
+ parser.ParseArgs(std::vector<std::string>{"--skip=8", "--if=/dev/null"});
+ null << parser.Help();
+ parser.Help(null);
+ null << parser;
+}