[ https://issues.apache.org/jira/browse/CLI-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16908600#comment-16908600 ]
Friedrich Clausen edited comment on CLI-297 at 8/16/19 1:22 AM: ---------------------------------------------------------------- This standalone test program reproduces the issue for me: {code:java} import org.apache.commons.cli.*; class CheckEmpty { public static void main(String[] args) { Option widgetCount = Option.builder() .longOpt("widget-count") .hasArg() .required() .build(); Options options = new Options(); options.addOption(widgetCount); CommandLineParser parser = new DefaultParser(); CommandLine commandLine; try { commandLine = parser.parse(options, args); if (commandLine.hasOption("widget-count")) { String optionArg = commandLine.getOptionValue("widget-count"); System.out.println("Received widget count of: " + optionArg); } } catch (ParseException e) { System.err.println("Problem parsing args: " + e); System.exit(1); } } } {code} was (Author: ftclausen): This standalone test program reproduces the issue for me: {code:java} import org.apache.commons.cli.*; class CheckEmpty { public static void main(String[] args) { Option widgetCount = Option.builder() .longOpt("widget-count") .hasArg() .required() .build(); Options options = new Options(); options.addOption(widgetCount); CommandLineParser parser = new DefaultParser(); CommandLine commandLine; try { commandLine = parser.parse(options, args); if (commandLine.hasOption("widget-count")) { String optionArg = commandLine.getOptionValue("widget-count"); System.out.println("Received widget count of: " + optionArg); } } catch (ParseException e) { System.err.println("Problem parsing args: " + e); System.exit(1); } } } {code} > Required argument empty checking not working with equals specified long option > ------------------------------------------------------------------------------ > > Key: CLI-297 > URL: https://issues.apache.org/jira/browse/CLI-297 > Project: Commons CLI > Issue Type: Bug > Components: CLI-1.x > Affects Versions: 1.4 > Environment: OS: macOS 10.14.6 > Java: Corretto-8.212.04.2 (build 1.8.0_212-b04) > Reporter: Friedrich Clausen > Priority: Minor > > When an option taking an argument is specified with a space the blank > checking works: > {code:none} > $ CheckEmpty --widget-count > org.apache.commons.cli.MissingOptionException: Missing required option: > widget-count > {code} > However when using the equals sign as a separator that checking does not > seem to apply > {code:none} > $ CheckEmpty --widget-count= > Received widget count of: > {code} > I'd expect it to throw an exception just like the space separated variety. -- This message was sent by Atlassian JIRA (v7.6.14#76016)