rkrisztian created CLI-302: ------------------------------ Summary: More user-friendly error handling for missing required arguments Key: CLI-302 URL: https://issues.apache.org/jira/browse/CLI-302 Project: Commons CLI Issue Type: Bug Components: CLI-1.x Affects Versions: 1.4 Reporter: rkrisztian
Currently when I specify a flag that requires an argument, but I actually don't specify that argument, I get the usage plus an exception. It would be nicer for the user if the exception did not happen: {noformat} $ myCliApp -a error: Missing argument for option: a usage: [options] Options: -a,--argument <arg> specify this argument Exception in thread "main" java.lang.NullPointerException: Cannot invoke method hasOption() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:34) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127) at groovy.cli.commons.CliBuilder.processSetAnnotation(CliBuilder.groovy:561) {noformat} And I cannot control this because I just call: {code:none} cli.parseFromInstance options, args {code} Thanks in advance. -- This message was sent by Atlassian Jira (v8.3.4#803005)