Example usage for org.apache.commons.cli Option getOpt

List of usage examples for org.apache.commons.cli Option getOpt

Introduction

In this page you can find the example usage for org.apache.commons.cli Option getOpt.

Prototype

public String getOpt() 

Source Link

Document

Retrieve the name of this Option.

Usage

From source file:ca.appbox.monitoring.jmx.jmxbox.commons.context.parser.CommandLineOptionsComparator.java

public int compare(Option option1, Option option2) {
    return displayOrder.get(option1.getOpt()).compareTo(displayOrder.get(option2.getOpt()));
}

From source file:com.marklogic.contentpump.utilities.CommandlineOption.java

public CommandlineOption(Option opt) throws IllegalArgumentException {
    super(opt.getOpt(), opt.hasArg(), opt.getDescription());

    this.setLongOpt(opt.getLongOpt());
    this.setRequired(opt.isRequired());
    this.setArgName(opt.getArgName());
    this.setArgs(opt.getArgs());
    this.setOptionalArg(opt.hasOptionalArg());
    this.setType(opt.getType());
    this.setValueSeparator(opt.getValueSeparator());
}

From source file:com.zenoss.zenpacks.zenjmx.OptionsPrinter.java

/**
 * Returns a user-readable representation of an Option
 *///from w ww .j  a va 2  s  .co  m
private String print(Option option) {
    return "  " + option.getOpt() + ": " + option.getDescription();
}

From source file:com.kylinolap.job.tools.OptionsHelper.java

public boolean hasOption(Option option) {
    return commandLine.hasOption(option.getOpt());
}

From source file:com.kylinolap.job.tools.OptionsHelper.java

public String getOptionValue(Option option) {
    return commandLine.getOptionValue(option.getOpt());
}

From source file:edu.mit.ll.graphulo.pig.backend.GraphuloStorageOptions.java

public long getLong(CommandLine cli, Option o) {
    String value = cli.getOptionValue(o.getOpt());

    return (null == value) ? null : Long.parseLong(value);
}

From source file:edu.mit.ll.graphulo.pig.backend.GraphuloStorageOptions.java

public int getInt(CommandLine cli, Option o) {
    String value = cli.getOptionValue(o.getOpt());

    return (null == value) ? null : Integer.parseInt(value);
}

From source file:de.weltraumschaf.groundzero.opt.commons.OptionComparator.java

/**
 * Finds the order position of a option configuration.
 *
 * The method throws a {@link IllegalArgumentException}, if the position can not be determined
 * of a given option./*ww w.  j  ava  2 s  .c o  m*/
 *
 * @param option must not be {@code null}
 * @return non negative integer
 */
int findPositionForKey(final Option option) {
    final String shortOption = option.getOpt();
    final String longOption = option.getLongOpt();

    for (OptionDescriptor desc : ORDER) {
        if (desc.getShortOption().equals(shortOption) || desc.getLongOption().equals(longOption)) {
            return ORDER.indexOf(desc);
        }
    }

    throw new IllegalArgumentException(String.format("Unconfigured option: %s!", option));
}

From source file:eu.alpinweiss.filegen.service.impl.FdrServiceImpl.java

@Override
public void run(String[] args) {

    if (injector == null) {
        throw new RuntimeException("Injector is null");
    }/*from   www  . j a  va2s .  co  m*/

    Model model = new Model();
    Map<String, Class<? extends CommandStep>> commandSteps = optionHolder.getCommandStepMap();
    Options options = optionHolder.getAppOptions();

    CommandLineParser parser = new PosixParser();
    try {
        CommandLine cmd = parser.parse(options, args);
        Option[] cmdOptions = cmd.getOptions();
        for (Option cmdOption : cmdOptions) {
            model.addParameter(cmdOption.getOpt(), cmdOption.getValue());
            model.addCommand(injector.getInstance(commandSteps.get(cmdOption.getOpt())));
        }
    } catch (ParseException e) {
        LOGGER.error(e.getMessage(), e);
    }

    commandRunner.run(model);
}

From source file:net.mitnet.tools.pdf.book.common.cli.CommandLineHelper.java

/**
 * Returns the Option value as an int.//www  . j  av  a2 s. c o  m
 */
public int getOptionValueAsInt(Option option) {
    return getOptionValueAsInt(option.getOpt());
}