diff --git a/CMakeLists.txt b/CMakeLists.txt index bd15501..9eaf6d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ endif() project(args CXX) set(PROJECT_DESCRIPTION "A simple, small, flexible, single-header C++11 argument parsing library. that is designed to appear somewhat similar to Python's argparse.") set(PROJECT_HOMEPAGE_URL "https://github.com/Taywee/args") -set(PROJECT_VERSION 6.2.7) +set(PROJECT_VERSION 6.3.0) option(ARGS_BUILD_EXAMPLE "Build example" ON) option(ARGS_BUILD_UNITTESTS "Build unittests" ON) diff --git a/Doxyfile b/Doxyfile index 1190a7c..ffd98af 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 = 6.2.7 +PROJECT_NUMBER = 6.3.0 # 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 1f8705e..69ccbf6 100644 --- a/args.hxx +++ b/args.hxx @@ -2,7 +2,7 @@ * * https://github.com/Taywee/args * - * Copyright (c) 2016-2020 Taylor C. Richberger and Pavel + * Copyright (c) 2016-2021 Taylor C. Richberger and Pavel * Belikov * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -33,10 +33,10 @@ #ifndef ARGS_HXX #define ARGS_HXX -#define ARGS_VERSION "6.2.7" +#define ARGS_VERSION "6.3.0" #define ARGS_VERSION_MAJOR 6 -#define ARGS_VERSION_MINOR 2 -#define ARGS_VERSION_PATCH 7 +#define ARGS_VERSION_MINOR 3 +#define ARGS_VERSION_PATCH 0 #include #include @@ -3242,6 +3242,14 @@ namespace args return count; } + int &operator *() noexcept { + return count; + } + + const int &operator *() const noexcept { + return count; + } + virtual void Reset() noexcept override { FlagBase::Reset(); @@ -3394,6 +3402,34 @@ namespace args return value; } + /** Get the value + */ + T &operator *() noexcept + { + return value; + } + + /** Get the value + */ + const T &operator *() const noexcept + { + return value; + } + + /** Get the value + */ + T *operator ->() noexcept + { + return &value; + } + + /** Get the value + */ + const T *operator ->() const noexcept + { + return &value; + } + /** Get the default value */ const T &GetDefault() noexcept @@ -3523,6 +3559,34 @@ namespace args return values; } + /** Get the value + */ + List &operator *() noexcept + { + return values; + } + + /** Get the values + */ + const List &operator *() const noexcept + { + return values; + } + + /** Get the values + */ + List *operator ->() noexcept + { + return &values; + } + + /** Get the values + */ + const List *operator ->() const noexcept + { + return &values; + } + iterator begin() noexcept { return values.begin(); @@ -3635,6 +3699,34 @@ namespace args return values; } + /** Get the value + */ + Container &operator *() noexcept + { + return values; + } + + /** Get the values + */ + const Container &operator *() const noexcept + { + return values; + } + + /** Get the values + */ + Container *operator ->() noexcept + { + return &values; + } + + /** Get the values + */ + const Container *operator ->() const noexcept + { + return &values; + } + virtual std::string Name() const override { return name + std::string("..."); @@ -3768,6 +3860,34 @@ namespace args return value; } + /** Get the value + */ + T &operator *() noexcept + { + return value; + } + + /** Get the value + */ + const T &operator *() const noexcept + { + return value; + } + + /** Get the value + */ + T *operator ->() noexcept + { + return &value; + } + + /** Get the value + */ + const T *operator ->() const noexcept + { + return &value; + } + virtual void Reset() noexcept override { ValueFlagBase::Reset(); @@ -3862,6 +3982,34 @@ namespace args return values; } + /** Get the value + */ + Container &operator *() noexcept + { + return values; + } + + /** Get the values + */ + const Container &operator *() const noexcept + { + return values; + } + + /** Get the values + */ + Container *operator ->() noexcept + { + return &values; + } + + /** Get the values + */ + const Container *operator ->() const noexcept + { + return &values; + } + virtual std::string Name() const override { return name + std::string("..."); @@ -3962,6 +4110,34 @@ namespace args return value; } + /** Get the value + */ + T &operator *() noexcept + { + return value; + } + + /** Get the value + */ + const T &operator *() const noexcept + { + return value; + } + + /** Get the value + */ + T *operator ->() noexcept + { + return &value; + } + + /** Get the value + */ + const T *operator ->() const noexcept + { + return &value; + } + virtual void Reset() noexcept override { PositionalBase::Reset(); @@ -4039,6 +4215,34 @@ namespace args return values; } + /** Get the value + */ + Container &operator *() noexcept + { + return values; + } + + /** Get the values + */ + const Container &operator *() const noexcept + { + return values; + } + + /** Get the values + */ + Container *operator ->() noexcept + { + return &values; + } + + /** Get the values + */ + const Container *operator ->() const noexcept + { + return &values; + } + virtual void Reset() noexcept override { PositionalBase::Reset(); @@ -4160,6 +4364,34 @@ namespace args return value; } + /** Get the value + */ + T &operator *() noexcept + { + return value; + } + + /** Get the value + */ + const T &operator *() const noexcept + { + return value; + } + + /** Get the value + */ + T *operator ->() noexcept + { + return &value; + } + + /** Get the value + */ + const T *operator ->() const noexcept + { + return &value; + } + virtual void Reset() noexcept override { PositionalBase::Reset(); @@ -4255,6 +4487,34 @@ namespace args return values; } + /** Get the value + */ + Container &operator *() noexcept + { + return values; + } + + /** Get the values + */ + const Container &operator *() const noexcept + { + return values; + } + + /** Get the values + */ + Container *operator ->() noexcept + { + return &values; + } + + /** Get the values + */ + const Container *operator ->() const noexcept + { + return &values; + } + virtual std::string Name() const override { return name + std::string("..."); diff --git a/conanfile.py b/conanfile.py index 7ac5978..0a75b3d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -2,7 +2,7 @@ class ArgsConan(ConanFile): name = "args" - version = "6.2.7" + version = "6.3.0" url = "https://github.com/Taywee/args" description = "A simple header-only C++ argument parser library." license = "MIT" diff --git a/meson.build b/meson.build index 2607f47..132e60d 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('args.hxx', ['cpp'], - version: '6.2.7', + version: '6.3.0', default_options: 'cpp_std=c++11', license: 'MIT' ) diff --git a/test.cxx b/test.cxx index 28e55ae..fb3ec53 100644 --- a/test.cxx +++ b/test.cxx @@ -59,9 +59,9 @@ TEST_CASE("Count flag works as expected", "[args]") REQUIRE(foo); REQUIRE(bar); REQUIRE_FALSE(baz); - REQUIRE(args::get(foo) == 4); - REQUIRE(args::get(bar) == 10); - REQUIRE(args::get(baz) == 7); + REQUIRE(*foo == 4); + REQUIRE(*bar == 10); + REQUIRE(*baz == 7); } TEST_CASE("Argument flags work as expected, with clustering", "[args]") @@ -74,12 +74,12 @@ TEST_CASE("Argument flags work as expected, with clustering", "[args]") args::Flag bix(parser, "BAZ", "test flag", {'x', "bix"}); parser.ParseArgs(std::vector{"-bftest", "--baz=7.555e2", "--bim", "c"}); REQUIRE(foo); - REQUIRE(args::get(foo) == "test"); + REQUIRE(*foo == "test"); REQUIRE(bar); REQUIRE(baz); - REQUIRE((args::get(baz) > 755.49 && args::get(baz) < 755.51)); + REQUIRE((*baz > 755.49 && *baz < 755.51)); REQUIRE(bim); - REQUIRE(args::get(bim) == 'c'); + REQUIRE(*bim == 'c'); REQUIRE_FALSE(bix); } @@ -100,12 +100,12 @@ TEST_CASE("Unified argument lists for match work", "[args]") args::Flag bix(parser, "BAZ", "test flag", {"bix"}); parser.ParseArgs(std::vector{"-bftest", "--baz=7.555e2", "--bim", "c"}); REQUIRE(foo); - REQUIRE(args::get(foo) == "test"); + REQUIRE(*foo == "test"); REQUIRE(bar); REQUIRE(baz); - REQUIRE((args::get(baz) > 755.49 && args::get(baz) < 755.51)); + REQUIRE((*baz > 755.49 && *baz < 755.51)); REQUIRE(bim); - REQUIRE(args::get(bim) == 'c'); + REQUIRE(*bim == 'c'); REQUIRE_FALSE(bix); } @@ -115,9 +115,9 @@ TEST_CASE("Get can be assigned to for non-reference types", "[args]") args::ValueFlag foo(parser, "FOO", "test flag", {'f', "foo"}); parser.ParseArgs(std::vector{"--foo=test"}); REQUIRE(foo); - REQUIRE(args::get(foo) == "test"); - args::get(foo) = "bar"; - REQUIRE(args::get(foo) == "bar"); + REQUIRE(*foo == "test"); + *foo = "bar"; + REQUIRE(*foo == "bar"); } TEST_CASE("Invalid argument parsing throws parsing exceptions", "[args]") @@ -134,7 +134,7 @@ TEST_CASE("Argument flag lists work as expected", "[args]") args::ArgumentParser parser("This is a test program.", "This goes after the options."); args::ValueFlagList foo(parser, "FOO", "test flag", {'f', "foo"}); parser.ParseArgs(std::vector{"--foo=7", "-f2", "-f", "9", "--foo", "42"}); - REQUIRE((args::get(foo) == std::vector{7, 2, 9, 42})); + REQUIRE((*foo == std::vector{7, 2, 9, 42})); } TEST_CASE("Argument flag lists use default values", "[args]") @@ -142,7 +142,7 @@ TEST_CASE("Argument flag lists use default values", "[args]") args::ArgumentParser parser("This is a test program.", "This goes after the options."); args::ValueFlagList foo(parser, "FOO", "test flag", {'f', "foo"}, {9, 7, 5}); parser.ParseArgs(std::vector()); - REQUIRE((args::get(foo) == std::vector{9, 7, 5})); + REQUIRE((*foo == std::vector{9, 7, 5})); } TEST_CASE("Argument flag lists replace default values", "[args]") @@ -150,7 +150,7 @@ TEST_CASE("Argument flag lists replace default values", "[args]") args::ArgumentParser parser("This is a test program.", "This goes after the options."); args::ValueFlagList foo(parser, "FOO", "test flag", {'f', "foo"}, {9, 7, 5}); parser.ParseArgs(std::vector{"--foo=7", "-f2", "-f", "9", "--foo", "42"}); - REQUIRE((args::get(foo) == std::vector{7, 2, 9, 42})); + REQUIRE((*foo == std::vector{7, 2, 9, 42})); } TEST_CASE("Positional lists work as expected", "[args]") @@ -158,7 +158,7 @@ TEST_CASE("Positional lists work as expected", "[args]") args::ArgumentParser parser("This is a test program.", "This goes after the options."); args::PositionalList foo(parser, "FOO", "test flag"); parser.ParseArgs(std::vector{"7", "2", "9", "42"}); - REQUIRE((args::get(foo) == std::vector{7, 2, 9, 42})); + REQUIRE((*foo == std::vector{7, 2, 9, 42})); } TEST_CASE("Positional lists use default values", "[args]") @@ -166,7 +166,7 @@ TEST_CASE("Positional lists use default values", "[args]") args::ArgumentParser parser("This is a test program.", "This goes after the options."); args::PositionalList foo(parser, "FOO", "test flag", {9, 7, 5}); parser.ParseArgs(std::vector()); - REQUIRE((args::get(foo) == std::vector{9, 7, 5})); + REQUIRE((*foo == std::vector{9, 7, 5})); } TEST_CASE("Positional lists replace default values", "[args]") @@ -174,7 +174,7 @@ TEST_CASE("Positional lists replace default values", "[args]") args::ArgumentParser parser("This is a test program.", "This goes after the options."); args::PositionalList foo(parser, "FOO", "test flag", {9, 7, 5}); parser.ParseArgs(std::vector{"7", "2", "9", "42"}); - REQUIRE((args::get(foo) == std::vector{7, 2, 9, 42})); + REQUIRE((*foo == std::vector{7, 2, 9, 42})); } #include @@ -184,7 +184,7 @@ TEST_CASE("Argument flag lists work with sets", "[args]") args::ArgumentParser parser("This is a test program.", "This goes after the options."); args::ValueFlagList foo(parser, "FOO", "test flag", {'f', "foo"}); parser.ParseArgs(std::vector{"--foo=7", "-fblah", "-f", "9", "--foo", "blah"}); - REQUIRE((args::get(foo) == std::unordered_set{"7", "9", "blah"})); + REQUIRE((*foo == std::unordered_set{"7", "9", "blah"})); } TEST_CASE("Positional arguments and positional argument lists work as expected", "[args]") @@ -195,11 +195,11 @@ TEST_CASE("Positional arguments and positional argument lists work as expected", args::PositionalList baz(parser, "BAZ", "test flag"); parser.ParseArgs(std::vector{"this is a test flag", "0", "a", "b", "c", "x", "y", "z"}); REQUIRE(foo); - REQUIRE((args::get(foo) == "this is a test flag")); + REQUIRE((*foo == "this is a test flag")); REQUIRE(bar); - REQUIRE(!args::get(bar)); + REQUIRE(!*bar); REQUIRE(baz); - REQUIRE((args::get(baz) == std::vector{'a', 'b', 'c', 'x', 'y', 'z'})); + REQUIRE((*baz == std::vector{'a', 'b', 'c', 'x', 'y', 'z'})); } TEST_CASE("The option terminator works as expected", "[args]") @@ -213,31 +213,31 @@ TEST_CASE("The option terminator works as expected", "[args]") args::ValueFlag obaz(parser, "BAZ", "test flag", {'a', "baz"}); parser.ParseArgs(std::vector{"--foo", "this is a test flag", "0", "a", "b", "--baz", "7.0", "c", "x", "y", "z"}); REQUIRE(foo); - REQUIRE((args::get(foo) == "this is a test flag")); + REQUIRE((*foo == "this is a test flag")); REQUIRE(bar); - REQUIRE(!args::get(bar)); + REQUIRE(!*bar); REQUIRE(baz); - REQUIRE((args::get(baz) == std::vector{"a", "b", "c", "x", "y", "z"})); + REQUIRE((*baz == std::vector{"a", "b", "c", "x", "y", "z"})); REQUIRE(ofoo); REQUIRE(!obar); REQUIRE(obaz); parser.ParseArgs(std::vector{"--foo", "this is a test flag", "0", "a", "--", "b", "--baz", "7.0", "c", "x", "y", "z"}); REQUIRE(foo); - REQUIRE((args::get(foo) == "this is a test flag")); + REQUIRE((*foo == "this is a test flag")); REQUIRE(bar); - REQUIRE(!args::get(bar)); + REQUIRE(!*bar); REQUIRE(baz); - REQUIRE((args::get(baz) == std::vector{"a", "b", "--baz", "7.0", "c", "x", "y", "z"})); + REQUIRE((*baz == std::vector{"a", "b", "--baz", "7.0", "c", "x", "y", "z"})); REQUIRE(ofoo); REQUIRE(!obar); REQUIRE(!obaz); parser.ParseArgs(std::vector{"--foo", "--", "this is a test flag", "0", "a", "b", "--baz", "7.0", "c", "x", "y", "z"}); REQUIRE(foo); - REQUIRE((args::get(foo) == "this is a test flag")); + REQUIRE((*foo == "this is a test flag")); REQUIRE(bar); - REQUIRE(!args::get(bar)); + REQUIRE(!*bar); REQUIRE(baz); - REQUIRE((args::get(baz) == std::vector{"a", "b", "--baz", "7.0", "c", "x", "y", "z"})); + REQUIRE((*baz == std::vector{"a", "b", "--baz", "7.0", "c", "x", "y", "z"})); REQUIRE(ofoo); REQUIRE(!obar); REQUIRE(!obaz); @@ -248,7 +248,7 @@ TEST_CASE("Positional lists work with sets", "[args]") args::ArgumentParser parser("This is a test program.", "This goes after the options."); args::PositionalList foo(parser, "FOO", "test positional"); parser.ParseArgs(std::vector{"foo", "FoO", "bar", "baz", "foo", "9", "baz"}); - REQUIRE((args::get(foo) == std::unordered_set{"foo", "FoO", "bar", "baz", "9"})); + REQUIRE((*foo == std::unordered_set{"foo", "FoO", "bar", "baz", "9"})); } @@ -260,7 +260,7 @@ TEST_CASE("Positionals that are unspecified evaluate false", "[args]") args::PositionalList baz(parser, "BAZ", "test flag"); parser.ParseArgs(std::vector{"this is a test flag again"}); REQUIRE(foo); - REQUIRE((args::get(foo) == "this is a test flag again")); + REQUIRE((*foo == "this is a test flag again")); REQUIRE_FALSE(bar); REQUIRE_FALSE(baz); } @@ -354,10 +354,10 @@ TEST_CASE("Custom types work", "[args]") args::Positional> ints(parser, "INTS", "This takes a pair of integers."); args::Positional, DoublesReader> doubles(parser, "DOUBLES", "This takes a pair of doubles."); parser.ParseArgs(std::vector{"1,2", "3.8,4"}); - REQUIRE(std::get<0>(args::get(ints)) == 1); - REQUIRE(std::get<1>(args::get(ints)) == 2); - REQUIRE((std::get<0>(args::get(doubles)) > 3.79 && std::get<0>(args::get(doubles)) < 3.81)); - REQUIRE((std::get<1>(args::get(doubles)) > 3.99 && std::get<1>(args::get(doubles)) < 4.01)); + REQUIRE(std::get<0>(*ints) == 1); + REQUIRE(std::get<1>(*ints) == 2); + REQUIRE((std::get<0>(*doubles) > 3.79 && std::get<0>(*doubles) < 3.81)); + REQUIRE((std::get<1>(*doubles) > 3.99 && std::get<1>(*doubles) < 4.01)); } TEST_CASE("Custom parser prefixes (dd-style)", "[args]") @@ -372,11 +372,11 @@ TEST_CASE("Custom parser prefixes (dd-style)", "[args]") args::ValueFlag output(parser, "BLOCK SIZE", "Block size", {"of"}); parser.ParseArgs(std::vector{"skip=8", "if=/dev/null"}); REQUIRE_FALSE(bs); - REQUIRE(args::get(bs) == 512); + REQUIRE(*bs == 512); REQUIRE(skip); - REQUIRE(args::get(skip) == 8); + REQUIRE(*skip == 8); REQUIRE(input); - REQUIRE(args::get(input) == "/dev/null"); + REQUIRE(*input == "/dev/null"); REQUIRE_FALSE(output); } @@ -392,11 +392,11 @@ TEST_CASE("Custom parser prefixes (Some Windows styles)", "[args]") args::ValueFlag output(parser, "BLOCK SIZE", "Block size", {"of"}); parser.ParseArgs(std::vector{"/skip:8", "/if:/dev/null"}); REQUIRE_FALSE(bs); - REQUIRE(args::get(bs) == 512); + REQUIRE(*bs == 512); REQUIRE(skip); - REQUIRE(args::get(skip) == 8); + REQUIRE(*skip == 8); REQUIRE(input); - REQUIRE(args::get(input) == "/dev/null"); + REQUIRE(*input == "/dev/null"); REQUIRE_FALSE(output); } @@ -486,17 +486,17 @@ TEST_CASE("Mapping types work as needed", "[args]") args::MapPositionalList mpl(parser, "MPL", "Maps string to an enum list", map); parser.ParseArgs(std::vector{"--mf=red", "--cimf=YeLLoW", "--mfl=bar", "foo", "--mfl=green", "red", "--mfl", "bar", "default"}); REQUIRE_FALSE(dmf); - REQUIRE(args::get(dmf) == MappingEnum::def); + REQUIRE(*dmf == MappingEnum::def); REQUIRE(mf); - REQUIRE(args::get(mf) == MappingEnum::red); + REQUIRE(*mf == MappingEnum::red); REQUIRE(cimf); - REQUIRE(args::get(cimf) == MappingEnum::yellow); + REQUIRE(*cimf == MappingEnum::yellow); REQUIRE(mfl); - REQUIRE((args::get(mfl) == std::vector{MappingEnum::bar, MappingEnum::green, MappingEnum::bar})); + REQUIRE((*mfl == std::vector{MappingEnum::bar, MappingEnum::green, MappingEnum::bar})); REQUIRE(mp); - REQUIRE((args::get(mp) == MappingEnum::foo)); + REQUIRE((*mp == MappingEnum::foo)); REQUIRE(mpl); - REQUIRE((args::get(mpl) == std::vector{MappingEnum::red, MappingEnum::def})); + REQUIRE((*mpl == std::vector{MappingEnum::red, MappingEnum::def})); REQUIRE_THROWS_AS(parser.ParseArgs(std::vector{"--mf=YeLLoW"}), args::MapError); } @@ -526,7 +526,7 @@ TEST_CASE("An exception should be thrown when a single-argument flag is matched REQUIRE_FALSE(bar); REQUIRE_FALSE(bix); REQUIRE(baz); - REQUIRE(args::get(baz) == MappingEnum::green); + REQUIRE(*baz == MappingEnum::green); } TEST_CASE("Sub-parsers should work through kick-out", "[args]") @@ -558,7 +558,7 @@ TEST_CASE("Sub-parsers should work through kick-out", "[args]") REQUIRE(foo1); REQUIRE_FALSE(bar1); REQUIRE(sub); - REQUIRE(args::get(sub) == MappingEnum::green); + REQUIRE(*sub == MappingEnum::green); REQUIRE_FALSE(foo2); REQUIRE(bar2); } @@ -603,7 +603,7 @@ TEST_CASE("Kick-out should work via all flags and value flags", "[args]") REQUIRE(c2); REQUIRE_FALSE(d2); REQUIRE(bar); - REQUIRE(args::get(bar) == "barvalue"); + REQUIRE(*bar == "barvalue"); REQUIRE_FALSE(a3); REQUIRE(b3); REQUIRE_FALSE(c3); @@ -617,7 +617,7 @@ TEST_CASE("Required flags work as expected", "[args]") args::ValueFlag bar(parser1, "bar", "bar", {'b', "bar"}); parser1.ParseArgs(std::vector{"-f", "42"}); - REQUIRE(foo.Get() == 42); + REQUIRE(*foo == 42); REQUIRE_THROWS_AS(parser1.ParseArgs(std::vector{"-b4"}), args::RequiredError); @@ -656,20 +656,20 @@ TEST_CASE("Implicit values work as expected", "[args]") args::ImplicitValueFlag j(parser, "parallel", "parallel", {'j', "parallel"}, 0, 1); args::Flag foo(parser, "FOO", "test flag", {'f', "foo"}); REQUIRE_NOTHROW(parser.ParseArgs(std::vector{"-j"})); - REQUIRE(args::get(j) == 0); + REQUIRE(*j == 0); REQUIRE_NOTHROW(parser.ParseArgs(std::vector{"-j4"})); - REQUIRE(args::get(j) == 4); + REQUIRE(*j == 4); REQUIRE_NOTHROW(parser.ParseArgs(std::vector{"-j", "4"})); - REQUIRE(args::get(j) == 4); + REQUIRE(*j == 4); REQUIRE_NOTHROW(parser.ParseArgs(std::vector{"-j", "-f"})); - REQUIRE(args::get(j) == 0); + REQUIRE(*j == 0); REQUIRE(foo); REQUIRE_NOTHROW(parser.ParseArgs(std::vector{"-f"})); - REQUIRE(args::get(j) == 1); + REQUIRE(*j == 1); REQUIRE_FALSE(j); } @@ -685,23 +685,23 @@ TEST_CASE("Nargs work as expected", "[args]") REQUIRE_THROWS_AS(args::Nargs(3, 2), args::UsageError); REQUIRE_NOTHROW(parser.ParseArgs(std::vector{"-a", "1", "2"})); - REQUIRE((args::get(a) == std::vector{1, 2})); + REQUIRE((*a == std::vector{1, 2})); REQUIRE_NOTHROW(parser.ParseArgs(std::vector{"-a", "1", "2", "-f"})); - REQUIRE((args::get(a) == std::vector{1, 2})); - REQUIRE(args::get(f) == true); + REQUIRE((*a == std::vector{1, 2})); + REQUIRE(f); REQUIRE_THROWS_AS(parser.ParseArgs(std::vector{"-a", "1"}), args::ParseError); REQUIRE_THROWS_AS(parser.ParseArgs(std::vector{"-a1"}), args::ParseError); REQUIRE_THROWS_AS(parser.ParseArgs(std::vector{"-a1", "2"}), args::ParseError); REQUIRE_NOTHROW(parser.ParseArgs(std::vector{"-b", "1", "-2", "-f"})); - REQUIRE((args::get(b) == std::vector{1, -2})); - REQUIRE(args::get(f) == true); + REQUIRE((*b == std::vector{1, -2})); + REQUIRE(f); REQUIRE_NOTHROW(parser.ParseArgs(std::vector{"-b", "1", "2", "3"})); - REQUIRE((args::get(b) == std::vector{1, 2, 3})); - REQUIRE(args::get(f) == false); + REQUIRE((*b == std::vector{1, 2, 3})); + REQUIRE(!f); std::vector vec; for (int be : b) @@ -717,12 +717,12 @@ TEST_CASE("Nargs work as expected", "[args]") REQUIRE_THROWS_AS(parser.ParseArgs(std::vector{"-a", "1", "2"}), args::ParseError); REQUIRE_NOTHROW(parser.ParseArgs(std::vector{"-c", "-f"})); - REQUIRE(args::get(c).empty()); - REQUIRE(args::get(f) == true); + REQUIRE(c->empty()); + REQUIRE(f); REQUIRE_NOTHROW(parser.ParseArgs(std::vector{"-cf"})); - REQUIRE((args::get(c) == std::vector{"f"})); - REQUIRE(args::get(f) == false); + REQUIRE((*c == std::vector{"f"})); + REQUIRE(!f); REQUIRE_THROWS_AS(parser.ParseArgs(std::vector{"-d"}), args::ParseError); REQUIRE_THROWS_AS(parser.ParseArgs(std::vector{"-b"}), args::ParseError); @@ -741,8 +741,8 @@ TEST_CASE("Simple commands work as expected", "[args]") p.ParseArgs(std::vector{"add", "--git-dir", "A", "B", "C", "D"}); REQUIRE(add); REQUIRE(!commit); - REQUIRE((args::get(pathsList) == std::vector{"B", "C", "D"})); - REQUIRE(args::get(gitdir) == "A"); + REQUIRE((*pathsList == std::vector{"B", "C", "D"})); + REQUIRE(*gitdir == "A"); } TEST_CASE("Subparser commands work as expected", "[args]") @@ -775,7 +775,7 @@ TEST_CASE("Subparser commands work as expected", "[args]") REQUIRE(add); REQUIRE(!commit); REQUIRE((paths == std::vector{"B", "C", "D"})); - REQUIRE(args::get(gitdir) == "A"); + REQUIRE(*gitdir == "A"); } TEST_CASE("Subparser commands with kick-out flags work as expected", "[args]") @@ -1196,16 +1196,16 @@ TEST_CASE("ValueParser works as expected", "[args]") args::PositionalList ds(p, "name", "description"); REQUIRE_NOTHROW(p.ParseArgs(std::vector{"-f", "a b"})); - REQUIRE(args::get(f) == "a b"); + REQUIRE(*f == "a b"); REQUIRE_NOTHROW(p.ParseArgs(std::vector{"-b", "a b"})); - REQUIRE(args::get(b).path == "a b"); + REQUIRE(b->path == "a b"); REQUIRE_NOTHROW(p.ParseArgs(std::vector{"-i", "42 "})); - REQUIRE(args::get(i) == 42); + REQUIRE(*i == 42); REQUIRE_NOTHROW(p.ParseArgs(std::vector{"-i", " 12"})); - REQUIRE(args::get(i) == 12); + REQUIRE(*i == 12); REQUIRE_THROWS_AS(p.ParseArgs(std::vector{"-i", "a"}), args::ParseError); REQUIRE_THROWS_AS(p.ParseArgs(std::vector{"-d", "b"}), args::ParseError); @@ -1431,7 +1431,7 @@ TEST_CASE("Required flags work as expected in noexcept mode", "[args]") argstest::ValueFlag bar(parser1, "bar", "bar", {'b', "bar"}); parser1.ParseArgs(std::vector{"-f", "42"}); - REQUIRE(foo.Get() == 42); + REQUIRE(*foo == 42); REQUIRE(parser1.GetError() == argstest::Error::None); parser1.ParseArgs(std::vector{"-b4"});