Options options = new Options();
options.addOption(Option.builder("1").hasArg().required().build());
options.addOption(Option.builder("2").hasArg().required().build());
CommandLineParser parser = new DefaultParser();
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd;
try {
cmd = parser.parse(options, args);
} catch (ParseException e) {
formatter.printHelp("-1=
-2=", options);
return;
}
System.out.println("Area: " + BackEnd.areaCalculation(
Float.parseFloat(cmd.getOptionValue("1")),
Float.parseFloat(cmd.getOptionValue("2"))));
}
}