argparse/test/test_version.cpp
Pranav Srinivas Kumar f3e65f69a9 Added --version as a special flag similar to --help
* ArgumentParser takes a second argument - the program version (std::string)
* Using --version or -v will print the program version and exit
2020-05-15 19:06:00 -05:00

13 lines
368 B
C++

#include <doctest.hpp>
#include <argparse/argparse.hpp>
using doctest::test_suite;
TEST_CASE("Users can print version and exit" * test_suite("version")) {
argparse::ArgumentParser program("cli-test", "1.9.0");
program.add_argument("-d", "--dir")
.required();
program.parse_args( { "test", "--version" });
REQUIRE(program.get("--version") == "1.9.0");
}