Mahadev created CLI-290:
---------------------------
Summary: check if all options are provided using CommandLine
Key: CLI-290
URL: https://issues.apache.org/jira/browse/CLI-290
Project: Commons CLI
Issue Type: New Feature
Components: Validation
Reporter: Mahadev
I want to ad check if Options which marked as Required are available or not
My use case is to have a method like below in CommandLine class
{code:java}
boolean hasAllRequiredOptions(){code}
Check below given expected code, (code kept uncompiled purposefully)
{code:java}
import org.apache.commons.cli.*;
public class CLITester {
public static void main(String[] args) throws ParseException {
Options options = new Options();
options.addRequiredOption("p", "print", false, "Send print request to
printer.")
.addRequiredOption("g", "gui", false, "Show GUI Application")
.addOption("n", "nothing", true, "No. of copies to print");
CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse(options, args);
if (!cmd.hasAllRequiredOptions()) { // I want to have method like this
which will check if all required options are available
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("CLITester", options);
}
}
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)