diff --git a/source/argparse/internal/command.d b/source/argparse/internal/command.d index 698a1c1..1adcacb 100644 --- a/source/argparse/internal/command.d +++ b/source/argparse/internal/command.d @@ -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)