public static void main(String[] args) throws Exception {
DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
ArgumentBuilder abuilder = new ArgumentBuilder();
GroupBuilder gbuilder = new GroupBuilder();
Option inputOpt = DefaultOptionCreator.inputOption().create();
Option outputOpt = DefaultOptionCreator.outputOption().create();
Option labelOpt = obuilder.withLongName("label").withRequired(true).withArgument(
abuilder.withName("label").withMinimum(1).withMaximum(1).create()).withDescription("The label of the file")
.withShortName("l").create();
Option analyzerOpt = obuilder.withLongName("analyzer").withArgument(
abuilder.withName("analyzer").withMinimum(1).withMaximum(1).create()).withDescription(
"The fully qualified class name of the analyzer to use. "
+ "Must have a no-arg constructor. Default is the StandardAnalyzer").withShortName("a").create();
Option charsetOpt = obuilder.withLongName("charset").withArgument(
abuilder.withName("charset").withMinimum(1).withMaximum(1).create()).withDescription(
"The character encoding of the input file").withShortName("c").create();
Option collapseOpt = obuilder.withLongName("collapse").withRequired(true).withArgument(
abuilder.withName("collapse").withMinimum(1).withMaximum(1).create()).withDescription(
"Collapse a whole directory to a single file, one doc per line").withShortName("p").create();
Option helpOpt = DefaultOptionCreator.helpOption();
Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(outputOpt).withOption(labelOpt)
.withOption(analyzerOpt).withOption(charsetOpt).withOption(collapseOpt).withOption(helpOpt).create();
try {
Parser parser = new Parser();
parser.setGroup(group);