List of usage examples for org.apache.commons.cli2.builder ArgumentBuilder create
public final Argument create()
From source file:com.gsinnovations.howdah.AbstractJob.java
/** Build an option with the given parameters. Name and description are * required.// w w w . j a va 2 s .com * * @param name the long name of the option prefixed with '--' on the command-line * @param shortName the short name of the option, prefixed with '-' on the command-line * @param description description of the option displayed in help method * @param hasArg true if the option has an argument. * @param required true if the option is required. * @param defaultValue default argument value, can be null. * @return the option. */ private static Option buildOption(String name, String shortName, String description, boolean hasArg, boolean required, String defaultValue) { DefaultOptionBuilder optBuilder = new DefaultOptionBuilder().withLongName(name).withDescription(description) .withRequired(required); if (shortName != null) { optBuilder.withShortName(shortName); } if (hasArg) { ArgumentBuilder argBuilder = new ArgumentBuilder().withName(name).withMinimum(1).withMaximum(1); if (defaultValue != null) { argBuilder = argBuilder.withDefault(defaultValue); } optBuilder.withArgument(argBuilder.create()); } return optBuilder.create(); }
From source file:my.mahout.AbstractJob.java
protected static Option buildOption(String name, String shortName, String description, boolean hasArg, int min, int max, boolean required, String defaultValue) { DefaultOptionBuilder optBuilder = new DefaultOptionBuilder().withLongName(name).withDescription(description) .withRequired(required);/* w w w . j a v a 2s. c o m*/ if (shortName != null) { optBuilder.withShortName(shortName); } if (hasArg) { ArgumentBuilder argBuilder = new ArgumentBuilder().withName(name).withMinimum(min).withMaximum(max); if (defaultValue != null) { argBuilder = argBuilder.withDefault(defaultValue); } optBuilder.withArgument(argBuilder.create()); } return optBuilder.create(); }
From source file:com.digitalpebble.behemoth.tika.TikaDriver.java
private Option buildOption(String name, String shortName, String description, boolean hasArg, boolean required, String defaultValue) {/*from w w w.j a va 2s .c o m*/ DefaultOptionBuilder optBuilder = new DefaultOptionBuilder().withLongName(name).withDescription(description) .withRequired(required); if (shortName != null) { optBuilder.withShortName(shortName); } if (hasArg) { ArgumentBuilder argBuilder = new ArgumentBuilder().withName(name).withMinimum(1).withMaximum(1); if (defaultValue != null) { argBuilder = argBuilder.withDefault(defaultValue); } optBuilder.withArgument(argBuilder.create()); } return optBuilder.create(); }
From source file:it.jnrpe.server.console.PluginCommand.java
private Option toOption(PluginOption po) { DefaultOptionBuilder oBuilder = new DefaultOptionBuilder(); oBuilder.withShortName(po.getOption()).withDescription(po.getDescription()) .withRequired("true".equalsIgnoreCase(po.getRequired())); if (po.getLongOpt() != null) { oBuilder.withLongName(po.getLongOpt()); }//from ww w . j a v a 2 s . c o m if (po.hasArgs()) { ArgumentBuilder aBuilder = new ArgumentBuilder(); if (po.getArgName() != null) { aBuilder.withName(po.getArgName()); } if (po.getArgsOptional()) { aBuilder.withMinimum(0); } if (po.getArgsCount() != null) { aBuilder.withMaximum(po.getArgsCount()); } else { aBuilder.withMaximum(1); } if (po.getValueSeparator() != null && po.getValueSeparator().length() != 0) { aBuilder.withInitialSeparator(po.getValueSeparator().charAt(0)); aBuilder.withSubsequentSeparator(po.getValueSeparator().charAt(0)); } oBuilder.withArgument(aBuilder.create()); } return oBuilder.create(); }
From source file:it.jnrpe.plugins.PluginOption.java
/** * Convert this {@link PluginOption} to the Option required by Apache. * Commons Cli.//from www . ja v a 2 s.co m * * @return The option object required by commons cli */ public Option toOption() { DefaultOptionBuilder oBuilder = new DefaultOptionBuilder(); oBuilder.withShortName(option).withDescription(description).withRequired(required); if (longOptionName != null) { oBuilder.withLongName(longOptionName); } if (hasArgs) { ArgumentBuilder aBuilder = new ArgumentBuilder(); if (argName != null) { aBuilder.withName(argName); } if (argsAreOptional) { aBuilder.withMinimum(0); } if (argsCount != null) { aBuilder.withMaximum(argsCount); } else { aBuilder.withMaximum(1); } if (argsValueSeparator != null && argsValueSeparator.length() != 0) { aBuilder.withInitialSeparator(argsValueSeparator.charAt(0)); aBuilder.withSubsequentSeparator(argsValueSeparator.charAt(0)); } oBuilder.withArgument(aBuilder.create()); } return oBuilder.create(); }
From source file:org.opencloudengine.flamingo.mapreduce.core.AbstractJob.java
/** * ? ? . ? ? ./*from w ww . ja v a2 s .c o m*/ * required. * * @param name ??? '--'? prefix ? ? * @param shortName ??? '--'? prefix ? ? ? * @param description ??? ? ? * @param hasArg ?? <tt>true</tt> * @param required ?? <tt>true</tt> * @param defaultValue ??? . <tt>null</tt>? . * @return */ protected static Option buildOption(String name, String shortName, String description, boolean hasArg, boolean required, String defaultValue) { DefaultOptionBuilder optBuilder = new DefaultOptionBuilder().withLongName(name).withDescription(description) .withRequired(required); if (shortName != null) { optBuilder.withShortName(shortName); } if (hasArg) { ArgumentBuilder argBuilder = new ArgumentBuilder().withName(name).withMinimum(1).withMaximum(1); if (defaultValue != null) { argBuilder = argBuilder.withDefault(defaultValue); } optBuilder.withArgument(argBuilder.create()); } return optBuilder.create(); }