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:org.azyva.dragom.tool.RootManagerTool.java

/**
 * Initializes the class.//  w ww.j  av  a 2s. com
 */
private synchronized static void init() {
    if (!RootManagerTool.indInit) {
        Option option;

        CliUtil.initJavaUtilLogging();

        RootManagerTool.options = new Options();

        option = new Option(null, null);
        option.setLongOpt("ind-allow-duplicate-modules");
        RootManagerTool.options.addOption(option);

        CliUtil.addStandardOptions(RootManagerTool.options);

        RootManagerTool.indInit = true;
    }
}

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

/**
 * Initializes the class./*from w  w w.  ja  v a2  s  .c  o  m*/
 */
private synchronized static void init() {
    if (!SetupJenkinsJobsTool.indInit) {
        Option option;

        CliUtil.initJavaUtilLogging();

        SetupJenkinsJobsTool.options = new Options();

        option = new Option(null, null);
        option.setLongOpt("items-created-file");
        option.setArgs(1);
        SetupJenkinsJobsTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("items-created-file-mode");
        option.setArgs(1);
        SetupJenkinsJobsTool.options.addOption(option);

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

        SetupJenkinsJobsTool.indInit = true;
    }
}

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

/**
 * Initializes the class.//from w ww.  j ava2  s.co  m
 */
private synchronized static void init() {
    if (!SwitchToDynamicVersionTool.indInit) {
        Option option;

        SwitchToDynamicVersionTool.options = new Options();

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

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

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

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

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

        SwitchToDynamicVersionTool.indInit = true;
    }
}

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

/**
 * Initializes the class./* w ww .  jav a2 s.com*/
 */
private synchronized static void init() {
    if (!TaskInvokerTool.indInit) {
        Option option;

        TaskInvokerTool.options = new Options();

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

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

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

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

        TaskInvokerTool.indInit = true;
    }
}

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

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

        CliUtil.initJavaUtilLogging();

        WorkspaceManagerTool.options = new Options();

        option = new Option(null, null);
        option.setLongOpt("commit-message");
        option.setArgs(1);
        WorkspaceManagerTool.options.addOption(option);

        option = new Option(null, null);
        option.setLongOpt("ind-skip-check-unsync-local-changes");
        WorkspaceManagerTool.options.addOption(option);

        CliUtil.addStandardOptions(WorkspaceManagerTool.options);

        WorkspaceManagerTool.indInit = true;
    }
}

From source file:org.callimachusproject.cli.CommandSet.java

public CommandOption require(String opt, String longOpt) {
    Option option = new Option(opt, longOpt);
    if (!opt.equals(longOpt)) {
        option.setLongOpt(longOpt);
    }/*from   w w w. jav a  2s  .  com*/
    option.setRequired(true);
    return new CommandOption(option);
}

From source file:org.callimachusproject.cli.CommandSet.java

public CommandOption option(String opt, String longOpt) {
    Option option = new Option(opt, longOpt);
    if (!opt.equals(longOpt)) {
        option.setLongOpt(longOpt);
    }// w w w  .  j a v  a 2s.co  m
    return new CommandOption(option);
}

From source file:org.cloudsimplus.automation.Start.java

/**
 * Parses options given by command line.
 * @param args the command line options/* w  w  w.  j a v  a 2  s.c  o m*/
 */
private boolean parseCommandLineOptions(String[] args) throws ParseException {
    options = new Options();
    Option option = new Option("v", "Enables CloudSim Plus Log (disabled by default)");
    option.setLongOpt("verbose");
    options.addOption(option);

    options.addOption("s", "Suppress simulation results");
    options.addOption("h", "Show usage help");
    options.addOption("c", "Print scenario configuration");

    CommandLineParser parser = new DefaultParser();
    this.cmd = parser.parse(options, args);

    /*
     * If after parsing the options there is an additional parameter to the YAML file name,
     * show the usage help.
     */
    if (cmd.getArgs().length == 0 || cmd.hasOption("h")) {
        showUsageHelp();
        return false;
    }

    return true;
}

From source file:org.codeseed.common.config.ext.CommandLineOptionsBuilder.java

/**
 * Potentially adds an option to the supplied collection. Used by the
 * {@link #build()} method to populate an options collection.
 *
 * @param options//from w  ww  .  j a  v  a 2  s  .c om
 *            the current collection of options
 * @param groups
 *            mappings of argument group identifiers to groups
 * @param method
 *            the configuration method to look up
 */
protected void addOption(Options options, Map<String, OptionGroup> groups, Method method) {
    final CommandLine commandLine = method.getAnnotation(CommandLine.class);

    // Iterate over the triggers; take the first values
    String opt = null;
    String longOpt = null;
    for (String trigger : commandLine.value()) {
        if (!options.hasOption(trigger)) {
            if (opt == null && trigger.length() == 1) {
                opt = trigger;
            } else if (longOpt == null) {
                longOpt = trigger;
            }
        }
    }

    // Either we can use the method name or there is no option being added
    if (opt == null && longOpt == null) {
        String methodOpt = LOWER_CAMEL.to(LOWER_HYPHEN, method.getName());
        if (!options.hasOption(methodOpt)) {
            longOpt = methodOpt;
        } else {
            // TODO Warn?
            return;
        }
    }

    // Create a new option
    Option option = new Option(opt, null);
    option.setLongOpt(longOpt);

    // Set the number of arguments based on the return type
    final Class<?> returnType = Primitives.wrap(method.getReturnType());
    if (returnType.equals(Boolean.class)) {
        option.setArgs(0);
    } else if (Iterable.class.isAssignableFrom(returnType)) {
        option.setArgs(commandLine.maximum());
    } else if (Map.class.isAssignableFrom(returnType)) {
        option.setArgs(2);
        option.setValueSeparator('=');
    } else {
        option.setArgs(1);
    }

    // Add some descriptive text
    if (bundle != null) {
        try {
            // TODO Does this make sense?
            String key = option.hasLongOpt() ? option.getLongOpt() : method.getName();
            option.setDescription(bundle.getString(key + ".description"));
        } catch (MissingResourceException e) {
            option.setDescription(null);
        }
    }

    // Set argument names
    if (bundle != null && option.getArgs() > 0) {
        try {
            option.setArgName(bundle.getString(method.getName() + ".argName"));
        } catch (MissingResourceException e) {
            option.setArgName(null);
        }
    }

    // Add to either the collection or to the option groups
    String groupKey = commandLine.groupId();
    if (groupKey.isEmpty()) {
        options.addOption(option);
    } else {
        OptionGroup group = groups.get(groupKey);
        if (group == null) {
            group = new OptionGroup();
            groups.put(groupKey, group);
        }
        group.addOption(option);
    }
}

From source file:org.deegree.tools.coverage.RTBClient.java

private static Options initOptions() {
    Options options = new Options();
    Option option = new Option(OPT_T_SRS, "the srs of the target raster (defaults to the source srs)");
    option.setArgs(1);//from  w ww. ja v  a 2 s  .c  o m
    option.setArgName("epsg code");
    options.addOption(option);

    option = new Option(OPT_RASTER_OUT_LOC_ABBREV, OPT_RASTER_OUT_LOC, true,
            "the output directory for the raster tree");
    option.setRequired(true);
    option.setArgs(1);
    option.setArgName("dir");
    options.addOption(option);

    option = new Option(OPT_TILE_SIZE, "the max tile size in pixel (defaults to " + DEFAULT_TILE_SIZE
            + "). the actual tile size is calculated to reduce 'black' borders" + " (see force_size)");
    option.setArgs(1);
    option.setArgName("size");
    options.addOption(option);

    option = new Option(OPT_FORCE_SIZE,
            "use the given tile_size as it is, do not calculate the optimal tile size");
    options.addOption(option);

    option = new Option(OPT_BBOX, "the target bbox");
    option.setArgs(1);
    option.setArgName("x0,y0,x1,y1");
    options.addOption(option);

    option = new Option(OPT_NUM_LEVELS,
            "the number of raster levels. when omitted, generate levels until a level contains one tile.");
    option.setArgs(1);
    option.setArgName("levels");
    options.addOption(option);

    option = new Option(OPT_RES, "the target resolution for the first level in units/px.");
    option.setArgs(1);
    option.setLongOpt("base_resolution");
    option.setArgName("units/px");
    options.addOption(option);

    option = new Option(OPT_INTERPOLATION, "the raster interpolation (nn: nearest neighbour, bl: bilinear");
    option.setArgs(1);
    option.setArgName("nn|bl");
    options.addOption(option);

    option = new Option(OPT_OUTPUT_TYPE_ABBREV, OPT_OUTPUT_TYPE, true,
            "the output format (defaults to " + DEFAULT_OUTPUT_FORMAT + ")");
    option.setArgs(1);
    option.setArgName(OPT_TYPE_DESC);
    options.addOption(option);

    option = new Option(OPT_NUM_THREADS, "the number of threads used.");
    option.setArgs(1);
    option.setArgName("threads");
    options.addOption(option);

    CommandUtils.addDefaultOptions(options);
    RasterOptionsParser.addRasterIOLineOptions(options);

    return options;
}