From 886ab64feff75ab3e30ac40fc0ad6eb91b8146ef Mon Sep 17 00:00:00 2001 From: "Taylor C. Richberger" Date: Fri, 6 May 2016 13:29:43 -0600 Subject: add overloads and tests, and improve help generation in general --- test.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test.cxx') 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 bs(parser, "BYTES", "Block size", args::Matcher({"bs"}), 512); + args::ArgFlag skip(parser, "BYTES", "Bytes to skip", args::Matcher({"skip"}), 0); + args::ArgFlag input(parser, "BLOCK SIZE", "Block size", args::Matcher({"if"})); + args::ArgFlag output(parser, "BLOCK SIZE", "Block size", args::Matcher({"of"})); + parser.ParseArgs(std::vector{"--skip=8", "--if=/dev/null"}); + null << parser.Help(); + parser.Help(null); + null << parser; +} -- cgit v1.2.1