Skip to content

Commit

Permalink
NArgsPattern -> nargs_pattern (to snake case)
Browse files Browse the repository at this point in the history
  • Loading branch information
hokacci committed Jun 21, 2022
1 parent 08943f4 commit b869b5a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions include/argparse/argparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<std::size_t>::max()};
break;
case NArgsPattern::AtLeastOne:
case nargs_pattern::at_least_one:
m_num_args_range = SizeRange{1, std::numeric_limits<std::size_t>::max()};
break;
}
Expand All @@ -522,7 +522,7 @@ class Argument {

Argument &remaining() {
m_accepts_optional_like_value = true;
return nargs(NArgsPattern::Any);
return nargs(nargs_pattern::any);
}

template <typename Iterator>
Expand Down
2 changes: 1 addition & 1 deletion test/test_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
8 changes: 4 additions & 4 deletions test/test_optional_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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"});
Expand Down
2 changes: 1 addition & 1 deletion test/test_positional_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit b869b5a

Please sign in to comment.