Java Code Examples for org.apache.commons.cli.Option#setOptionalArg()
The following examples show how to use
org.apache.commons.cli.Option#setOptionalArg() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PigStorage.java From spork with Apache License 2.0 | 6 votes |
private Options populateValidOptions() { Options validOptions = new Options(); validOptions.addOption("schema", false, "Loads / Stores the schema of the relation using a hidden JSON file."); validOptions.addOption("noschema", false, "Disable attempting to load data schema from the filesystem."); validOptions.addOption(TAG_SOURCE_FILE, false, "Appends input source file name to beginning of each tuple."); validOptions.addOption(TAG_SOURCE_PATH, false, "Appends input source file path to beginning of each tuple."); validOptions.addOption("tagsource", false, "Appends input source file name to beginning of each tuple."); Option overwrite = new Option(" ", "Overwrites the destination."); overwrite.setLongOpt("overwrite"); overwrite.setOptionalArg(true); overwrite.setArgs(1); overwrite.setArgName("overwrite"); validOptions.addOption(overwrite); return validOptions; }
Example 2
Source File: OptionBuilder.java From datawave with Apache License 2.0 | 5 votes |
/** * Creates an Option using OptionBuilder's State and the given parameters. * * @param opt * short representation of the option * @param longOpt * long representation of the option * @param desc * descibes the function of the option * @return the new Option */ public Option create(final String opt, final String longOpt, final String desc) { final Option option = new Option(opt, desc); option.setLongOpt(longOpt); option.setArgs(args); option.setRequired(required); option.setOptionalArg(optionalArg); option.setType(type); option.setValueSeparator(valSeparator); return option; }
Example 3
Source File: CommandFactory.java From scheduling with GNU Affero General Public License v3.0 | 5 votes |
protected Options createOptions(Collection<CommandSet.Entry> entries) { Options options = new Options(); for (CommandSet.Entry entry : entries) { Option option = new Option(entry.opt(), entry.longOpt(), entry.hasArgs(), entry.description()); option.setArgName(entry.argNames()); option.setArgs(entry.numOfArgs()); option.setOptionalArg(entry.hasOptionalArg()); options.addOption(option); } return options; }
Example 4
Source File: GatewayCommandLine.java From knox with Apache License 2.0 | 5 votes |
private static Options createCommandLine() { Options options = new Options(); options.addOption( HELP_SHORT, HELP_LONG, false, res.helpMessage() ); options.addOption( VERSION_SHORT, VERSION_LONG, false, res.versionHelpMessage() ); Option redeploy = new Option( REDEPLOY_SHORT, REDEPLOY_LONG, true, res.redeployHelpMessage() ); redeploy.setOptionalArg( true ); options.addOption( redeploy ); options.addOption( PERSIST_SHORT, PERSIST_LONG, false, res.persistMasterHelpMessage() ); options.addOption( NOSTART_SHORT, NOSTART_LONG, false, res.nostartHelpMessage() ); return options; }
Example 5
Source File: CliModel.java From seed with Mozilla Public License 2.0 | 5 votes |
CliModel(Set<Field> fields) { for (Field field : fields) { CliOption optionAnnotation = field.getAnnotation(CliOption.class); CliArgs argsAnnotation = field.getAnnotation(CliArgs.class); if (optionAnnotation != null) { Option option = new Option( optionAnnotation.name(), optionAnnotation.longName(), optionAnnotation.valueCount() > 0 || optionAnnotation.valueCount() == -1, optionAnnotation.description() ); if (optionAnnotation.valueCount() == -1) { option.setArgs(Option.UNLIMITED_VALUES); } else if (optionAnnotation.valueCount() > 0) { option.setArgs(optionAnnotation.valueCount()); } option.setValueSeparator(optionAnnotation.valueSeparator()); option.setRequired(optionAnnotation.mandatory()); option.setOptionalArg(!optionAnnotation.mandatoryValue()); optionAnnotations.add(optionAnnotation); optionFields.add(field); options.addOption(option); } else if (argsAnnotation != null) { mandatoryArgsCount = argsAnnotation.mandatoryCount(); argsField = field; } } }