Skip to content

Instantly share code, notes, and snippets.

@wspeirs
Created January 18, 2013 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wspeirs/4569404 to your computer and use it in GitHub Desktop.
Save wspeirs/4569404 to your computer and use it in GitHub Desktop.
Methods for creation an Option
Options options = new Options();
// create the simple option without using the OptionBuilder
options.addOption("o", "opt", false, "An option, no args");
// simple help option using the builder
options.addOption(OptionBuilder.withLongOpt("help")
.create("h"));
// an option with a value separator, defaults to =
options.addOption(OptionBuilder.withValueSeparator()
.withDescription("Java style property")
.create("D"));
// an option with an argument, no short version, and is required
options.addOption(OptionBuilder.withLongOpt("file")
.withArgName("input-file") // also need hasArg() or won't work
.hasArg()
.withDescription("The input file")
.create());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment