Fixed: GSA-392 @arguments with just a short name get the wrong argument bindings

-- Now blows up if an argument begins with -.  Implementation isn't pretty, as it actually blows up during Queue extension creation with a somewhat obscure error message but at least its something.
This commit is contained in:
Mark DePristo 2012-08-17 10:35:25 -04:00
parent 4c0f198d48
commit a3d2764d11
1 changed files with 17 additions and 0 deletions

View File

@ -26,6 +26,7 @@
package org.broadinstitute.sting.commandline;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import java.lang.annotation.Annotation;
import java.util.List;
@ -147,6 +148,9 @@ public class ArgumentDefinition {
this.exclusiveOf = exclusiveOf;
this.validation = validation;
this.validOptions = validOptions;
validateName(shortName);
validateName(fullName);
}
/**
@ -192,6 +196,9 @@ public class ArgumentDefinition {
else
shortName = null;
validateName(shortName);
validateName(fullName);
this.ioType = ioType;
this.argumentType = argumentType;
this.fullName = fullName;
@ -277,4 +284,14 @@ public class ArgumentDefinition {
String validation = (String)CommandLineUtils.getValue(annotation, "validation");
return validation.trim().length() > 0 ? validation.trim() : null;
}
/**
* Make sure the argument's name is valid
*
* @param name
*/
private void validateName(final String name) {
if ( name != null && name.startsWith("-") )
throw new ReviewedStingException("Invalid argument definition: " + name + " begins with a -");
}
}