Skip to content

Commit

Permalink
Additional edge case check
Browse files Browse the repository at this point in the history
  • Loading branch information
rambaut committed Nov 7, 2024
1 parent b4c7111 commit 86fc52b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dr/app/util/Arguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public int parseArguments(String[] arguments) throws ArgumentException {
int index = findArgument(arguments, option.label, option.shortLabel);
if (index != -1) {

boolean hasShortLabel = option.shortLabel != null && !option.shortLabel.isEmpty();
if (optionIndex[index] != -1) {
throw new ArgumentException("Argument, " + arguments[index] + " overlaps with another argument");
}
Expand All @@ -252,7 +253,8 @@ public int parseArguments(String[] arguments) throws ArgumentException {
String arg = "";
if (arguments[index].charAt(1) != ARGUMENT_CHARACTER.charAt(0) &&
!arguments[index].startsWith(option.label) &&
arguments[index].length() > option.shortLabel.length() + 1) {
(hasShortLabel &&
arguments[index].length() > option.shortLabel.length() + 1)) {
arg = arguments[index].substring(option.label.length() + 1);
}

Expand Down

0 comments on commit 86fc52b

Please sign in to comment.