Skip to content

Commit

Permalink
Required positional arguments must come before optional ones
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-zherikov committed Nov 6, 2023
1 parent 74c9991 commit 2eedcc4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/argparse/internal/command.d
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ package(argparse) Command createCommand(Config config, COMMAND_TYPE, CommandInfo

static if(pos < positionalArgs.length - 1)
static assert(info.minValuesCount.get == info.maxValuesCount.get, "Positional argument with index "~pos.stringof~" in "~COMMAND_TYPE.stringof~" has variable number of values.");

static if(i > 0 && info.required)
static assert(positionalArgs[i-1].required, "Required positional argument with index "~pos.stringof~" comes after optional positional argument");
}}

static foreach(info; argumentInfos)
Expand Down

0 comments on commit 2eedcc4

Please sign in to comment.