Details
-
New Feature
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
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
boolean hasAllRequiredOptions()
Check below given expected code, (code kept uncompiled purposefully)
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); } } }