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

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

Introduction

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

Prototype

public void setLongOpt(String longOpt) 

Source Link

Document

Sets the long name of this Option.

Usage

From source file:net.sourceforge.squirrel_sql.client.ApplicationArguments.java

private Option createAnOptionWithArgument(String[] argInfo) {
    OptionBuilder.withArgName(argInfo[0]);
    OptionBuilder.hasArg();/*  ww  w  .  j  av  a2s.co m*/
    OptionBuilder.withDescription(argInfo[2]);
    Option opt = OptionBuilder.create(argInfo[0]);
    if (!isStringEmpty(argInfo[1])) {
        opt.setLongOpt(argInfo[1]);
    }
    return opt;
}

From source file:org.akvo.flow.InstanceConfigurator.java

private static Options getOptions() {

    Options options = new Options();

    Option orgName = new Option("on", "Organzation name");
    orgName.setLongOpt("orgName");
    orgName.setArgs(1);//from   ww w .jav a  2 s . c  o  m
    orgName.setRequired(true);

    Option awsId = new Option("ak", "AWS Access Key");
    awsId.setLongOpt("awsKey");
    awsId.setArgs(1);
    awsId.setRequired(true);

    Option awsSecret = new Option("as", "AWS Access Secret");
    awsSecret.setLongOpt("awsSecret");
    awsSecret.setArgs(1);
    awsSecret.setRequired(true);

    Option bucketName = new Option("bn", "AWS S3 bucket name");
    bucketName.setLongOpt("bucketName");
    bucketName.setArgs(1);
    bucketName.setRequired(true);

    Option gaeServer = new Option("gae", "GAE instance id - The `x` in https://x.appspot.com");
    gaeServer.setLongOpt("gaeId");
    gaeServer.setArgs(1);
    gaeServer.setRequired(true);

    Option emailFrom = new Option("ef", "Sender email - NOTE: Must be developer in GAE instance");
    emailFrom.setLongOpt("emailFrom");
    emailFrom.setArgs(1);
    emailFrom.setRequired(false);

    Option emailTo = new Option("et", "Recipient email of error notifications");
    emailTo.setLongOpt("emailTo");
    emailTo.setArgs(1);
    emailTo.setRequired(true);

    Option flowServices = new Option("fs", "FLOW Services url, e.g. http://services.akvoflow.org");
    flowServices.setLongOpt("flowServices");
    flowServices.setArgs(1);
    flowServices.setRequired(true);

    Option outputFolder = new Option("o", "Output folder for configuration files");
    outputFolder.setLongOpt("outFolder");
    outputFolder.setArgs(1);
    outputFolder.setRequired(true);

    Option alias = new Option("a", "Instance alias, e.g. instance.akvoflow.org");
    alias.setLongOpt("alias");
    alias.setArgs(1);
    alias.setRequired(true);

    Option signingKey = new Option("sk", "Signing Key");
    signingKey.setLongOpt("signingKey");
    signingKey.setArgs(1);
    signingKey.setRequired(true);

    options.addOption(orgName);
    options.addOption(awsId);
    options.addOption(awsSecret);
    options.addOption(bucketName);
    options.addOption(gaeServer);
    options.addOption(emailFrom);
    options.addOption(emailTo);
    options.addOption(outputFolder);
    options.addOption(flowServices);
    options.addOption(alias);
    options.addOption(signingKey);

    return options;
}

From source file:org.apache.activemq.apollo.util.cli.OptionBuilder.java

public Option op() {
    Option option = new Option(id != null ? id : " ", description);
    option.setLongOpt(name);
    option.setRequired(required);/*from w  ww  . j  a  v a 2  s  .  c  om*/
    option.setOptionalArg(optional);
    option.setType(type);
    option.setValueSeparator(sperator);
    if (arg != null && args == -1) {
        args = 1;
    }
    option.setArgs(args);
    option.setArgName(arg);
    return option;
}

From source file:org.apache.pig.builtin.PigStorage.java

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("overwrite", "Overwrites the destination.");
    overwrite.setLongOpt("overwrite");
    overwrite.setOptionalArg(true);/*from ww w  .  ja v a2s  .  co m*/
    overwrite.setArgs(1);
    overwrite.setArgName("overwrite");
    validOptions.addOption(overwrite);

    return validOptions;
}

From source file:org.apache.tika.batch.builders.CommandLineParserBuilder.java

private Option buildOption(Node optionNode) {
    NamedNodeMap map = optionNode.getAttributes();
    String opt = getString(map, "opt", "");
    String description = getString(map, "description", "");
    String longOpt = getString(map, "longOpt", "");
    boolean isRequired = getBoolean(map, "required", false);
    boolean hasArg = getBoolean(map, "hasArg", false);
    if (opt.trim().length() == 0 || description.trim().length() == 0) {
        throw new IllegalArgumentException("Must specify at least option and description");
    }//from  w  w  w.  ja  va  2  s .  c  o  m
    Option option = new Option(opt, description);
    if (longOpt.trim().length() > 0) {
        option.setLongOpt(longOpt);
    }
    if (isRequired) {
        option.setRequired(true);
    }
    if (hasArg) {
        option.setArgs(1);
    }
    return option;
}

From source file:org.azyva.dragom.cliutil.CliUtil.java

/**
 * Utility method to add standard Option's.
 * <p>/*from  w w  w  .  j ava 2 s .c om*/
 * The user properties and tools properties Option's are added depending on
 * whether user properties and tool properties are supported.
 * <p>
 * The following Option's are also added:
 * <ul>
 * <li>Workspace
 * <li>Specifying whether confirmation is required
 * <li>Specifying whether confirmation is required for a particular context
 * <li>Help
 * </ul>
 * Used by tools when initializing Options.
 *
 * @param options Options.
 */
public static void addStandardOptions(Options options) {
    Option option;

    Util.applyDragomSystemProperties();

    if (Util.isNotNullAndTrue(System.getProperty(CliUtil.SYS_PROPERTY_IND_USER_PROPERTIES))) {
        option = new Option(null, null);
        option.setLongOpt(CliUtil.getUserPropertiesFileCommandLineOption());
        option.setArgs(1);
        options.addOption(option);
    }

    if (Util.isNotNullAndTrue(System.getProperty(CliUtil.SYS_PROPERTY_IND_SINGLE_TOOL_PROPERTIES))) {
        option = new Option("D", null);
        option.setValueSeparator('=');
        option.setArgs(2);
        options.addOption(option);
    }

    if (Util.isNotNullAndTrue(System.getProperty(CliUtil.SYS_PROPERTY_IND_TOOL_PROPERTIES))) {
        option = new Option(null, null);
        option.setLongOpt(CliUtil.getToolPropertiesFileCommandLineOption());
        option.setArgs(1);
        options.addOption(option);
    }

    option = new Option(null, null);
    option.setLongOpt(CliUtil.getWorkspacePathCommandLineOption());
    option.setArgs(1);
    options.addOption(option);

    option = new Option(null, null);
    option.setLongOpt(CliUtil.getNoConfirmCommandLineOption());
    options.addOption(option);

    option = new Option(null, null);
    option.setLongOpt(CliUtil.getNoConfirmContextCommandLineOption());
    option.setArgs(1);
    options.addOption(option);

    option = new Option(null, null);
    option.setLongOpt(CliUtil.getHelpCommandLineOption());
    options.addOption(option);
}

From source file:org.azyva.dragom.cliutil.CliUtil.java

/**
 * Utility method to add Option's related to the root {@link ModuleVersion}.
 * <p>// w  w w  .ja  v  a2 s  .  c  om
 * The following Option's are added:
 * <ul>
 * <li>Root {@link ModuleVersion}
 * <li>{@link ReferencePathMatcherByElement}
 * <li>Exclude ReferencePathMatcherByElement
 * </ul>
 * Used by tools that use root {@link ModuleVersion}'s when initializing Options.
 *
 * @param options Options.
 */
public static void addRootModuleVersionOptions(Options options) {
    Option option;

    Util.applyDragomSystemProperties();

    option = new Option(null, null);
    option.setLongOpt(CliUtil.getRootModuleVersionCommandLineOption());
    option.setArgs(1);
    options.addOption(option);

    option = new Option(null, null);
    option.setLongOpt(CliUtil.getReferencePathMatcherCommandLineOption());
    option.setArgs(1);
    options.addOption(option);

    option = new Option(null, null);
    option.setLongOpt(CliUtil.getExcludeReferencePathMatcherCommandLineOption());
    option.setArgs(1);
    options.addOption(option);
}

From source file:org.azyva.dragom.tool.CreateStaticVersionTool.java

/**
 * Initializes the class.//from   w ww  .  j av a2s .c o  m
 */
private synchronized static void init() {
    if (!CreateStaticVersionTool.indInit) {
        Option option;

        CreateStaticVersionTool.options = new Options();

        option = new Option(null, null);
        option.setLongOpt("workspace-path");
        option.setArgs(1);
        CreateStaticVersionTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("root-module-version");
        option.setArgs(1);
        CreateStaticVersionTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("reference-graph-path-matcher");
        option.setArgs(1);
        CreateStaticVersionTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("no-confirm");
        CreateStaticVersionTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("help");
        CreateStaticVersionTool.options.addOption(option);

        CreateStaticVersionTool.indInit = true;
    }
}

From source file:org.azyva.dragom.tool.GenericRootModuleVersionJobInvokerTool.java

/**
 * Initializes the class./*w w w . j a v a 2  s  .co  m*/
 */
private synchronized static void init() {
    if (!GenericRootModuleVersionJobInvokerTool.indInit) {
        Option option;
        GenericRootModuleVersionJobInvokerTool.options = new Options();

        CliUtil.initJavaUtilLogging();

        // TODO: Should probably put these in some properties file (i18n).
        option = new Option(null, null);
        option.setLongOpt("no-avoid-reentry");
        GenericRootModuleVersionJobInvokerTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("no-handle-static-version");
        GenericRootModuleVersionJobInvokerTool.options.addOption(option);

        CliUtil.addStandardOptions(GenericRootModuleVersionJobInvokerTool.options);
        CliUtil.addRootModuleVersionOptions(GenericRootModuleVersionJobInvokerTool.options);

        GenericRootModuleVersionJobInvokerTool.indInit = true;
    }
}

From source file:org.azyva.dragom.tool.ReferenceGraphReportTool.java

/**
 * Initializes the class.//from w  w  w .j  a  v a 2s.co  m
 */
private synchronized static void init() {
    if (!ReferenceGraphReportTool.indInit) {
        Option option;

        CliUtil.initJavaUtilLogging();

        ReferenceGraphReportTool.options = new Options();

        option = new Option(null, null);
        option.setLongOpt("output-format");
        option.setArgs(1);
        ReferenceGraphReportTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("graph");
        ReferenceGraphReportTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("avoid-redundancy");
        ReferenceGraphReportTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("module-versions");
        ReferenceGraphReportTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("only-multiple-versions");
        ReferenceGraphReportTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("only-matched-modules");
        ReferenceGraphReportTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("most-recent-version-in-reference-graph");
        ReferenceGraphReportTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("most-recent-static-version-in-scm");
        ReferenceGraphReportTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("reference-paths");
        ReferenceGraphReportTool.options.addOption(option);

        CliUtil.addStandardOptions(ReferenceGraphReportTool.options);
        CliUtil.addRootModuleVersionOptions(ReferenceGraphReportTool.options);

        ReferenceGraphReportTool.indInit = true;
    }
}