diff --git a/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java b/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java index 51d32d002..e009030e6 100644 --- a/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java +++ b/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java @@ -232,8 +232,9 @@ public abstract class CommandLineProgram { System.exit(result); } catch (ParseException e) { - logger.fatal("Unable to pass command line arguments: " + e.getMessage() ); clp.parser.printHelp( clp.getRunningInstructions() ); + // Rethrow the exception to exit with an error. + throw e; } catch (Exception e) { // we catch all exceptions here. if it makes it to this level, we're in trouble. Let's bail! diff --git a/java/src/org/broadinstitute/sting/utils/cmdLine/ParsingEngine.java b/java/src/org/broadinstitute/sting/utils/cmdLine/ParsingEngine.java index 80b5515f5..85dce8a89 100755 --- a/java/src/org/broadinstitute/sting/utils/cmdLine/ParsingEngine.java +++ b/java/src/org/broadinstitute/sting/utils/cmdLine/ParsingEngine.java @@ -430,8 +430,12 @@ class MissingArgumentException extends ParseException { private static String formatArguments( Collection missingArguments ) { StringBuilder sb = new StringBuilder(); - for( ArgumentDefinition missingArgument: missingArguments ) - sb.append( String.format("Argument with name '%s' is missing.%n", missingArgument.fullName) ); + for( ArgumentDefinition missingArgument: missingArguments ) { + if( missingArgument.shortName != null ) + sb.append( String.format("%nArgument with name '--%s' (-%s) is missing.", missingArgument.fullName, missingArgument.shortName) ); + else + sb.append( String.format("%nArgument with name '--%s' is missing.", missingArgument.fullName) ); + } return sb.toString(); } } @@ -447,7 +451,7 @@ class InvalidArgumentException extends ParseException { private static String formatArguments( Collection invalidArguments ) { StringBuilder sb = new StringBuilder(); for( ArgumentMatch invalidArgument: invalidArguments ) - sb.append( String.format("Argument with name '%s' isn't defined.%n", invalidArgument.label) ); + sb.append( String.format("%nArgument with name '%s' isn't defined.", invalidArgument.label) ); return sb.toString(); } } @@ -464,7 +468,7 @@ class InvalidArgumentValueException extends ParseException { StringBuilder sb = new StringBuilder(); for( int index: invalidValues.indices.keySet() ) for( String value: invalidValues.indices.get(index) ) - sb.append( String.format("Invalid argument value '%s' at position %d.%n", value, index) ); + sb.append( String.format("%nInvalid argument value '%s' at position %d.", value, index) ); return sb.toString(); } } @@ -480,7 +484,7 @@ class TooManyValuesForArgumentException extends ParseException { private static String formatArguments( Collection arguments ) { StringBuilder sb = new StringBuilder(); for( ArgumentMatch argument: arguments ) - sb.append( String.format("Argument '%s' has to many values: %s", argument.label, Arrays.deepToString(argument.values().toArray())) ); + sb.append( String.format("%nArgument '%s' has to many values: %s.", argument.label, Arrays.deepToString(argument.values().toArray())) ); return sb.toString(); } } @@ -496,7 +500,7 @@ class ArgumentsAreMutuallyExclusiveException extends ParseException { private static String formatArguments( Collection> arguments ) { StringBuilder sb = new StringBuilder(); for( Pair argument: arguments ) - sb.append( String.format("Arguments '%s' and '%s' are mutually exclusive.", argument.first.definition.fullName, argument.second.definition.fullName ) ); + sb.append( String.format("%nArguments '%s' and '%s' are mutually exclusive.", argument.first.definition.fullName, argument.second.definition.fullName ) ); return sb.toString(); }