From b869b5a209f6f2963988fbcd5a7ec62ddd60d573 Mon Sep 17 00:00:00 2001 From: Yoshihiro Hokazono Date: Wed, 22 Jun 2022 07:07:59 +0900 Subject: [PATCH] NArgsPattern -> nargs_pattern (to snake case) --- include/argparse/argparse.hpp | 20 ++++++++++---------- test/test_actions.cpp | 2 +- test/test_optional_arguments.cpp | 8 ++++---- test/test_positional_arguments.cpp | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/argparse/argparse.hpp b/include/argparse/argparse.hpp index f248fb65..5c21bcb3 100644 --- a/include/argparse/argparse.hpp +++ b/include/argparse/argparse.hpp @@ -359,10 +359,10 @@ class SizeRange { } }; -enum class NArgsPattern { - ZeroOrOne, - Any, - AtLeastOne +enum class nargs_pattern { + zero_or_one, + any, + at_least_one }; enum class default_arguments : unsigned int { @@ -505,15 +505,15 @@ class Argument { return *this; } - Argument &nargs(NArgsPattern num_args_pattern) { - switch (num_args_pattern) { - case NArgsPattern::ZeroOrOne: + Argument &nargs(nargs_pattern pattern) { + switch (pattern) { + case nargs_pattern::zero_or_one: m_num_args_range = SizeRange{0, 1}; break; - case NArgsPattern::Any: + case nargs_pattern::any: m_num_args_range = SizeRange{0, std::numeric_limits::max()}; break; - case NArgsPattern::AtLeastOne: + case nargs_pattern::at_least_one: m_num_args_range = SizeRange{1, std::numeric_limits::max()}; break; } @@ -522,7 +522,7 @@ class Argument { Argument &remaining() { m_accepts_optional_like_value = true; - return nargs(NArgsPattern::Any); + return nargs(nargs_pattern::any); } template diff --git a/test/test_actions.cpp b/test/test_actions.cpp index 95f83379..5b0ef765 100644 --- a/test/test_actions.cpp +++ b/test/test_actions.cpp @@ -126,7 +126,7 @@ TEST_CASE("Users can use actions on nargs=ANY arguments" * argparse::ArgumentParser program("sum"); int result = 0; - program.add_argument("all").nargs(argparse::NArgsPattern::Any).action( + program.add_argument("all").nargs(argparse::nargs_pattern::any).action( [](int &sum, std::string const &value) { sum += std::stoi(value); }, std::ref(result)); diff --git a/test/test_optional_arguments.cpp b/test/test_optional_arguments.cpp index e0961a64..f0bbf393 100644 --- a/test/test_optional_arguments.cpp +++ b/test/test_optional_arguments.cpp @@ -114,8 +114,8 @@ TEST_CASE("Parse 2 optional arguments of many values" * test_suite("optional_arguments")) { GIVEN("a program that accepts 2 optional arguments of many values") { argparse::ArgumentParser program("test"); - program.add_argument("-i").nargs(argparse::NArgsPattern::Any).scan<'i', int>(); - program.add_argument("-s").nargs(argparse::NArgsPattern::Any); + program.add_argument("-i").nargs(argparse::nargs_pattern::any).scan<'i', int>(); + program.add_argument("-s").nargs(argparse::nargs_pattern::any); WHEN("provided no argument") { THEN("the program accepts it and gets empty container") { @@ -156,8 +156,8 @@ TEST_CASE("Parse an optional argument of many values" GIVEN("a program that accepts an optional argument of many values" " and a positional argument of many values") { argparse::ArgumentParser program("test"); - program.add_argument("-s").nargs(argparse::NArgsPattern::Any); - program.add_argument("input").nargs(argparse::NArgsPattern::Any); + program.add_argument("-s").nargs(argparse::nargs_pattern::any); + program.add_argument("input").nargs(argparse::nargs_pattern::any); WHEN("provided no argument") { program.parse_args({"test"}); diff --git a/test/test_positional_arguments.cpp b/test/test_positional_arguments.cpp index c3c5b931..459f5dc8 100644 --- a/test/test_positional_arguments.cpp +++ b/test/test_positional_arguments.cpp @@ -142,7 +142,7 @@ TEST_CASE("Parse positional nargs=ANY arguments" * GIVEN("a program that accepts an optional argument and nargs=ANY positional arguments") { argparse::ArgumentParser program("test"); program.add_argument("-o"); - program.add_argument("input").nargs(argparse::NArgsPattern::Any); + program.add_argument("input").nargs(argparse::nargs_pattern::any); WHEN("provided no argument") { THEN("the program accepts it and gets empty container") {