FlagsImpl flags = new FlagsImpl();
CmdLineParser.registerHandler(List.class, StringListOptionHandler.class);
CmdLineParser.registerHandler(Long.class, LongOptionHandler.class);
CmdLineParser cmdLineParser = new CmdLineParser(flags);
try {
cmdLineParser.parseArgument(strings);
} catch (CmdLineException e) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
cmdLineParser.printUsage(stream);
throw new InvalidFlagException(e.getMessage(), stream.toString());
}