public static void main (String[] args)
{
CommandLineParser parser = new GnuParser ();
Options options = new Options ();
options.addOption (new HelpOption ());
NumberOption numberOption = new NumberOption ("Specify the number of passwords to generate");
options.addOption (numberOption);
try {
// parse the command line arguments
CommandLine line = parser.parse (options, args);
if (line.hasOption (HelpOption.cValue)) {
HelpFormatter hf = new HelpFormatter ();
hf.printHelp (PasswordGenerator.class.toString (), options);
}
else {
int number = numberOption.parse ();
System.out.println ("Generating " + number + " passwords.");
for (int i = 0; i < number; i++) {
System.out.println (PasswordGenerator.generate (9));
}
}