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

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

Introduction

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

Prototype

public void setArgName(String argName) 

Source Link

Document

Sets the display name for the argument value.

Usage

From source file:de.uni_koblenz.jgralab.gretl.GReTLRunner.java

public GReTLRunner() {
    String toolString = "java " + GReTLRunner.class.getName();
    String versionString = JGraLab.getInfo(false);

    oh = new OptionHandler(toolString, versionString);
    Option transform = new Option("t", "transformation", true,
            "(required) The GReTL transformation that should be executed.");
    transform.setArgName("gretl-file");
    transform.setRequired(true);/*from  w  ww .  ja v a  2s.c  o  m*/
    oh.addOption(transform);

    Option schema = new Option("s", "schema", true,
            "(optional) The name of the target schema. " + "Defaults to foo.bar.BazSchema.");
    schema.setArgName("schema-name");
    schema.setRequired(false);
    oh.addOption(schema);

    Option graphclass = new Option("g", "graphclass", true,
            "(optional) The name of the target graph class. " + "Defaults to BazGraph.");
    graphclass.setArgName("graphclass");
    graphclass.setRequired(false);
    oh.addOption(graphclass);

    Option viz = new Option("z", "visualize", false,
            "(optional) Additionally create a PDF viz of the output graph.");
    viz.setRequired(false);
    oh.addOption(viz);

    Option reverseViz = new Option("r", "reverse-edges", false,
            "(optional) When -z is given, print edges pointing bottom-up.");
    reverseViz.setRequired(false);
    oh.addOption(reverseViz);

    Option debugExecution = new Option("d", "debug", false,
            "(optional) Print the target graph after each transformation op.");
    debugExecution.setRequired(false);
    oh.addOption(debugExecution);

    Option output = new Option("o", "output", true,
            "(optional) The file to store the target graph to.  If many input "
                    + "models are to be transformed, this has no effect.");
    output.setRequired(false);
    debugExecution.setArgName("target-graph-file");
    oh.addOption(output);

    // TODO: Basically, -u should exclude the usage of -s/-g.
    Option useSourceSchema = new Option("u", "use-source-schema", false,
            "(optional) Use the source schema as target schema. "
                    + "In that case, no schema modifications may be performed by the transformation.");
    useSourceSchema.setRequired(false);
    oh.addOption(useSourceSchema);

    // TODO: Basically, -i should exclude the usage of -s/-g.
    Option inPlace = new Option("i", "in-place", false, "(optional) Use the source graph as target graph. "
            + "In that case, no schema modifications may be performed by the transformation.");
    inPlace.setRequired(false);
    oh.addOption(inPlace);

    oh.setArgumentCount(Option.UNLIMITED_VALUES);
    oh.setArgumentName("input-graph");
    oh.setOptionalArgument(false);
}

From source file:com.net2plan.cli.CLINet2Plan.java

/**
 * Default constructor.//from w w w.j a v a2 s.c o m
 *
 * @param args Command-line arguments
 */
public CLINet2Plan(String args[]) {
    try {
        SystemUtils.configureEnvironment(CLINet2Plan.class, UserInterface.CLI);

        for (Class<? extends Plugin> plugin : PluginSystem.getPlugins(ICLIModule.class)) {
            try {
                ICLIModule instance = ((Class<? extends ICLIModule>) plugin).newInstance();
                modes.put(instance.getModeName(), instance.getClass());
            } catch (NoClassDefFoundError e) {
                e.printStackTrace();
                throw new Net2PlanException("Class " + e.getMessage() + " cannot be found. A dependence for "
                        + plugin.getSimpleName() + " is missing?");
            } catch (InstantiationException | IllegalAccessException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        }

        Option helpOption = new Option("help", true,
                "Show the complete help information. 'modeName' is optional");
        helpOption.setArgName("modeName");
        helpOption.setOptionalArg(true);

        Option modeOption = new Option("mode", true,
                "Mode: " + StringUtils.join(StringUtils.toArray(modes.keySet()), ", "));
        modeOption.setArgName("modeName");
        modeOption.setOptionalArg(true);

        OptionGroup group = new OptionGroup();
        group.addOption(modeOption);
        group.addOption(helpOption);

        options.addOptionGroup(group);

        CommandLineParser parser = new CommandLineParser();
        CommandLine cli = parser.parse(options, args);

        if (cli.hasOption("help")) {
            String mode = cli.getOptionValue("help");
            System.out.println(mode == null ? getCompleteHelp() : getModeHelp(mode));
        } else if (!cli.hasOption("mode")) {
            System.out.println(getMainHelp());
        } else {
            String mode = cli.getOptionValue("mode");

            if (modes.containsKey(mode)) {
                ICLIModule modeInstance = modes.get(mode).newInstance();

                try {
                    modeInstance.executeFromCommandLine(args);
                } catch (Net2PlanException | JOMException ex) {
                    if (ErrorHandling.isDebugEnabled())
                        ErrorHandling.printStackTrace(ex);

                    System.out.println("Execution stopped");
                    System.out.println();
                    System.out.println(ex.getMessage());
                } catch (ParseException ex) {
                    System.out.println("Bad syntax: " + ex.getMessage());
                    System.out.println();
                    System.out.println(getModeHelp(mode));
                } catch (Throwable ex) {
                    Throwable ex1 = ErrorHandling.getInternalThrowable(ex);
                    if (ex1 instanceof Net2PlanException || ex1 instanceof JOMException) {
                        if (ErrorHandling.isDebugEnabled())
                            ErrorHandling.printStackTrace(ex);

                        System.out.println("Execution stopped");
                        System.out.println();
                        System.out.println(ex1.getMessage());
                    } else if (ex1 instanceof ParseException) {
                        System.out.println("Bad syntax: " + ex1.getMessage());
                        System.out.println();
                        System.out.println(getModeHelp(mode));
                    } else {
                        System.out.println("Execution stopped. An unexpected error happened");
                        System.out.println();
                        ErrorHandling.printStackTrace(ex1);
                    }
                }
            } else {
                throw new IllegalModeException("Bad mode - " + mode);
            }
        }
    } catch (IllegalModeException e) {
        System.out.println(e.getMessage());
        System.out.println();
        System.out.println(getMainHelp());
    } catch (ParseException e) {
        System.out.println("Bad syntax: " + e.getMessage());
        System.out.println();
        System.out.println(getMainHelp());
    } catch (Net2PlanException e) {
        if (ErrorHandling.isDebugEnabled())
            ErrorHandling.printStackTrace(e);
        System.out.println(e.getMessage());
    } catch (Throwable e) {
        ErrorHandling.printStackTrace(e);
    }
}

From source file:com.buildml.main.commands.CliCommandScanBuild.java

@Override
public Options getOptions() {
    Options opts = new Options();

    /* add the --trace-file option */
    Option traceFileOpt = new Option("f", "trace-file", true,
            "Specify the name of the trace file to write/read.");
    traceFileOpt.setArgName("file-name");
    opts.addOption(traceFileOpt);/*from  w ww  . j  av a  2  s. c o m*/

    /* add the --trace-only option */
    Option traceOnlyOpt = new Option("t", "trace-only", false,
            "Trace the shell command, but don't create a database.");
    opts.addOption(traceOnlyOpt);

    /* add the --read-trace option */
    Option readTraceOpt = new Option("r", "read-trace", false,
            "Read an existing trace file, creating a new database.");
    opts.addOption(readTraceOpt);

    /* add the --debug-level option */
    Option dumpTraceOpt = new Option("d", "debug-level", true,
            "Debug level (0 = none, 1 = brief, 2 = detailed).");
    opts.addOption(dumpTraceOpt);

    /* add the -c option */
    Option useShellOpt = new Option("c", "command-string", false,
            "Execute the quoted string as the whole command line.");
    opts.addOption(useShellOpt);

    /* add the --log-file option */
    Option logFileOpt = new Option("l", "log-file", true,
            "File for capturing debug information (default: cfs.log).");
    logFileOpt.setArgName("file-name");
    opts.addOption(logFileOpt);

    return opts;
}

From source file:dioscuri.CommandLineInterface.java

private void initOptions() {
    commandLineOptions = new Options();

    /* ? *//*from   ww  w . ja  v a 2  s  .  c  o m*/
    commandLineOptions.addOption("?", "help", false, "print this message");
    /* h */
    commandLineOptions.addOption("h", "hide", false, "hides the GUI");
    /* r */
    commandLineOptions.addOption("r", "autorun", false, "emulator will directly start emulation process");
    /* e */
    commandLineOptions.addOption("e", "exit", false,
            "used for testing purposes, will cause Dioscuri to exit immediately");
    /* s */
    commandLineOptions.addOption("s", "autoshutdown", false,
            "emulator will shutdown automatically when emulation process is finished");

    /* c */
    Option config = new Option("c", "config", true, "loads a custom config xml file");
    config.setArgName("file");
    commandLineOptions.addOption(config);

    /* f */
    config = new Option("f", "floppy", true, "loads a custom floppy image");
    config.setArgName("file");
    commandLineOptions.addOption(config);

    /* d1 */
    config = new Option("d1", "harddisk1", true, "loads a custom first hard disk image");
    config.setArgName("file");
    commandLineOptions.addOption(config);

    /* d2 */
    config = new Option("d2", "harddisk2", true, "loads a custom second hard disk image");
    config.setArgName("file");
    commandLineOptions.addOption(config);

    /* a */
    config = new Option("a", "architecture", true, "sets the cpu's architecture");
    config.setArgName("'16'|'32'");
    commandLineOptions.addOption(config);

    /* b */
    config = new Option("b", "boot", true, "sets the boot drive");
    config.setArgName("'floppy'|'harddisk'");
    commandLineOptions.addOption(config);

    /* m */
    config = new Option("m", "mouse", true, "enables or disables the mouse");
    config.setArgName("'enabled'|'disabled'");
    commandLineOptions.addOption(config);
}

From source file:lu.uni.adtool.tools.Clo.java

public Clo() {
    this.options = new org.apache.commons.cli.Options();
    this.options.addOption("h", "help", false, Options.getMsg("clo.help.txt"));
    this.options.addOption("v", "version", false, Options.getMsg("clo.version.txt"));
    //     this.options.addOption("a", "all-domains", false, Options.getMsg("clo.allDomains.txt"));
    this.options.addOption("D", "no-derived", false, Options.getMsg("clo.derived.txt"));
    this.options.addOption("m", "mark-editable", false, Options.getMsg("clo.markEditable.txt"));
    this.options.addOption("L", "no-labels", false, Options.getMsg("clo.labels.txt"));
    this.options.addOption("C", "no-computed", false, Options.getMsg("clo.computed.txt"));
    // this.options.addOption("r", "rank", false,
    // Options.getMsg("clo.rank.txt"));

    Option option = new Option("o", "open", true, Options.getMsg("clo.open.txt"));
    // Set option c to take 1 to oo arguments
    option.setArgs(Option.UNLIMITED_VALUES);
    option.setArgName("file_1>...<file_N");
    this.options.addOption(option);
    option = new Option("i", "import", true, Options.getMsg("clo.import.txt"));
    option.setArgName("file");
    this.options.addOption(option);
    option = new Option("x", "export", true, Options.getMsg("clo.export.txt"));
    option.setArgName("file");
    this.options.addOption(option);
    option = new Option("d", "domain", true, Options.getMsg("clo.domain.txt"));
    //     option.setValueSeparator(',');
    //     option.setArgs(1);
    option.setArgName("domainID");
    this.options.addOption(option);
    option = new Option("r", "rank", true, Options.getMsg("clo.rank.txt"));
    option.setArgs(1);//from   w w  w  .  ja  va2  s.  c  o  m
    option.setArgName("rankNo");
    this.options.addOption(option);
    option = new Option("s", "size", true, Options.getMsg("clo.size.txt"));
    option.setArgs(1);
    option.setArgName("X>x<Y");
    this.options.addOption(option);
    this.toOpen = null;
}

From source file:edu.cornell.med.icb.geo.tools.CalculateRanks.java

private void proccess(final String[] args) throws IOException {
    // create the Options
    final Options options = new Options();

    // help/*from ww  w . j  a va 2 s.  c o  m*/
    options.addOption("h", "help", false,
            "print this message. This program compares the performance measures obtained "
                    + "with each gene list and determines the rank of each gene list.");

    // input file name
    final Option inputOption = new Option("i", "input", true,
            "specify the path to the statistics file created by MicroarrayTrainEvaluate.");
    inputOption.setArgName("file");
    inputOption.setRequired(true);
    options.addOption(inputOption);

    // output file name
    final Option outputOption = new Option("o", "output", true,
            "specify the destination file where post-processed statistics will be written");
    outputOption.setArgName("file");
    outputOption.setRequired(true);
    options.addOption(outputOption);

    // tallies file name
    final Option talliesOption = new Option("t", "tallies", true,
            "specify the file where tallies of rank per gene list will be written");
    talliesOption.setArgName("file");
    talliesOption.setRequired(false);
    options.addOption(talliesOption);

    // filter by shuffle test P-value
    final Option filterShuffleTestOption = new Option("f", "filter-shuffle-test", false,
            "indicate that only those results that pass the shuffle significance test should be used to calculate ranks and tallies.");
    filterShuffleTestOption.setRequired(false);

    options.addOption(filterShuffleTestOption);

    // parse the command line arguments
    CommandLine line = null;
    try {
        // create the command line parser
        final CommandLineParser parser = new BasicParser();
        line = parser.parse(options, args, true);

    } catch (ParseException e) {
        System.err.println(e.getMessage());
        usage(options);
        System.exit(1);
    }
    // print help and exit
    if (line.hasOption("h")) {
        usage(options);
        System.exit(0);
    }
    this.filterWithShuffleTest = line.hasOption("f");
    if (this.filterWithShuffleTest) {
        System.out.println("Filtering classification results by shuffle test.");
    }
    postProcess(line.getOptionValue("i"), line.getOptionValue("o"), line.getOptionValue("t"));
}

From source file:edu.vt.middleware.crypt.KeyStoreCli.java

/** {@inheritDoc} */
protected void initOptions() {
    super.initOptions();

    final Option keystore = new Option(OPT_STORE, true, "keystore file");
    keystore.setArgName("filepath");
    keystore.setOptionalArg(false);/*from   w w  w.  ja  va 2 s  .c  o m*/

    final Option pass = new Option(OPT_PASS, true, "keystore password");
    pass.setArgName("password");
    pass.setOptionalArg(false);

    final Option type = new Option(OPT_TYPE, true, "keystore type, e.g. BKS (default), JKS");
    type.setArgName("name");
    type.setOptionalArg(false);

    final Option alias = new Option(OPT_ALIAS, true,
            "alias assigned to imported item or alias of item to export");
    alias.setArgName("name");
    alias.setOptionalArg(false);

    final Option cert = new Option(OPT_CERT, true,
            "X.509 certificate file; " + "encoding determined by file extension (der|pem)");
    cert.setArgName("filepath");
    cert.setOptionalArg(false);

    final Option key = new Option(OPT_KEY, true, "DER-encoded PKCS#8 or PEM-encoded SSLeay private key; "
            + "encoding determined by file extension (der|pem)");
    key.setArgName("filepath");
    key.setOptionalArg(false);

    final Option keyalg = new Option(OPT_KEYALG, true,
            "private key algorithm name; assumes RSA if not specified");
    keyalg.setArgName("algorithm");
    keyalg.setOptionalArg(false);

    options.addOption(keystore);
    options.addOption(pass);
    options.addOption(type);
    options.addOption(alias);
    options.addOption(cert);
    options.addOption(key);
    options.addOption(keyalg);
    options.addOption(new Option(OPT_LIST, "list keystore contents"));
    options.addOption(new Option(OPT_IMPORT, "import cert or cert/key pair"));
    options.addOption(new Option(OPT_EXPORT, "export cert or cert/key pair"));
}

From source file:kieker.tools.logReplayer.FilesystemLogReplayerStarter.java

@Override
protected void addAdditionalOptions(final Options options) {
    Option option;

    option = new Option("c", CMD_OPT_NAME_MONITORING_CONFIGURATION, true,
            "Configuration to use for the Kieker monitoring instance");
    option.setArgName(OPTION_EXAMPLE_FILE_MONITORING_PROPERTIES);
    option.setRequired(false);/*from   w w w  .  j  a va  2 s.co m*/
    option.setValueSeparator('=');
    options.addOption(option);

    option = new Option("i", CMD_OPT_NAME_INPUTDIRS, true, "Log directories to read data from");
    option.setArgName("dir1 ... dirN");
    option.setRequired(false);
    option.setArgs(Option.UNLIMITED_VALUES);
    options.addOption(option);

    option = new Option("k", CMD_OPT_NAME_KEEPORIGINALLOGGINGTIMESTAMPS, true,
            "Replay the original logging timestamps (defaults to true)?");
    option.setArgName("true|false");
    option.setRequired(false);
    option.setValueSeparator('=');
    options.addOption(option);

    option = new Option("r", CMD_OPT_NAME_REALTIME, true, "Replay log data in realtime?");
    option.setArgName("true|false");
    option.setRequired(false);
    option.setValueSeparator('=');
    options.addOption(option);

    option = new Option("n", CMD_OPT_NAME_NUM_REALTIME_WORKERS, true,
            "Number of worker threads used in realtime mode (defaults to 1).");
    option.setArgName("num");
    option.setRequired(false);
    options.addOption(option);

    option = new Option("a", CMD_OPT_NAME_REALTIME_ACCELERATION_FACTOR, true,
            "Factor by which to accelerate (>1.0) or slow down (<1.0) the replay in realtime mode (defaults to 1.0, i.e., no acceleration/slow down).");
    option.setArgName("factor");
    option.setRequired(false);
    option.setValueSeparator('=');
    options.addOption(option);

    option = new Option(null, CMD_OPT_NAME_IGNORERECORDSBEFOREDATE, true,
            "Records logged before this date (UTC timezone) are ignored (disabled by default).");
    option.setArgName(DATE_FORMAT_PATTERN_CMD_USAGE_HELP);
    option.setRequired(false);
    options.addOption(option);

    option = new Option(null, CMD_OPT_NAME_IGNORERECORDSAFTERDATE, true,
            "Records logged after this date (UTC timezone) are ignored (disabled by default).");
    option.setArgName(DATE_FORMAT_PATTERN_CMD_USAGE_HELP);
    option.setRequired(false);
    options.addOption(option);
}

From source file:com.zimbra.cs.store.file.BlobConsistencyUtil.java

private BlobConsistencyUtil() {
    options = new Options();

    options.addOption(new Option("h", LO_HELP, false, "Display this help message."));
    options.addOption(//from  w w  w  .  j a v a2s. c  o m
            new Option("v", LO_VERBOSE, false, "Display verbose output.  Display stack trace on error."));
    options.addOption(new Option(null, LO_SKIP_SIZE_CHECK, false, "Skip blob size check."));
    options.addOption(new Option(null, LO_OUTPUT_USED_BLOBS, false,
            "Output listing of all blobs referenced by the mailbox(es)"));

    Option o = new Option(null, LO_VOLUMES, true,
            "Specify which volumes to check.  If not specified, check all volumes.");
    o.setArgName("volume-ids");
    options.addOption(o);

    o = new Option("m", LO_MAILBOXES, true,
            "Specify which mailboxes to check.  If not specified, check all mailboxes.");
    o.setArgName("mailbox-ids");
    options.addOption(o);

    o = new Option(null, LO_UNEXPECTED_BLOB_LIST, true, "Write the paths of any unexpected blobs to a file.");
    o.setArgName("path");
    options.addOption(o);

    o = new Option(null, LO_USED_BLOB_LIST, true, "Write the paths of all used blobs to a file.");
    o.setArgName("path");
    options.addOption(o);

    options.addOption(null, LO_MISSING_BLOB_DELETE_ITEM, false, "Delete any items that have a missing blob.");

    o = new Option(null, LO_EXPORT_DIR, true, "Target directory for database export files.");
    o.setArgName("path");
    options.addOption(o);

    options.addOption(null, LO_NO_EXPORT, false, "Delete items without exporting.");
    options.addOption(new Option(null, LO_INCORRECT_REVISION_RENAME_FILE, false,
            "Rename the file on disk when the revision number doesn't match."));
}

From source file:net.nharyes.drivecopy.Main.java

private void composeOptions() {

    // file option
    Option file = OptionBuilder.create('f');
    file.setLongOpt("file");
    file.setArgs(1);//from ww w . j  ava 2s  . c  o  m
    file.setArgName("path");
    file.setDescription("where path is the file to upload/download/replace.");

    // directory option
    Option directory = OptionBuilder.create('d');
    directory.setLongOpt("directory");
    directory.setArgs(1);
    directory.setArgName("path");
    directory.setDescription(
            "where path is the local directory to upload/download/replace (it will be archived into a single remote file).");

    // file and directory group
    OptionGroup group = new OptionGroup();
    group.addOption(file);
    group.addOption(directory);
    group.setRequired(true);
    options.addOptionGroup(group);

    // compression level option
    Option level = OptionBuilder.create('l');
    level.setLongOpt("level");
    level.setArgs(1);
    level.setArgName("num");
    level.setOptionalArg(true);
    level.setType(Integer.class);
    level.setDescription(
            "where num is the compression level from 0 to 9. Used when uploading/replacing directories. The default value is 0.");
    options.addOption(level);

    // delete option
    Option delete = OptionBuilder.create('D');
    delete.setLongOpt("delete");
    delete.setOptionalArg(true);
    delete.setType(Boolean.class);
    delete.setDescription("delete local file/directory after remote entry uploaded/replaced.");
    options.addOption(delete);

    // log option
    Option log = OptionBuilder.create('L');
    log.setLongOpt("log");
    log.setArgs(1);
    log.setArgName("file");
    log.setType(String.class);
    log.setDescription("where file is the log file to write");
    options.addOption(log);

    // MIME type option
    Option mimeType = OptionBuilder.create('m');
    mimeType.setLongOpt("mimetype");
    mimeType.setArgs(1);
    mimeType.setArgName("type");
    mimeType.setType(String.class);
    mimeType.setDescription(
            "where type is the MIME type string to set for the remote entry. The default values are 'application/octet-stream' for files and 'application/zip' for compressed directories.");
    options.addOption(mimeType);

    // skip revision option
    Option skipRevision = OptionBuilder.create('s');
    skipRevision.setLongOpt("skiprevision");
    skipRevision.setOptionalArg(true);
    skipRevision.setType(Boolean.class);
    skipRevision.setDescription("do not create a new revision when replacing remote entry.");
    options.addOption(skipRevision);

    // check MD5 option
    Option checkMd5 = OptionBuilder.create('c');
    checkMd5.setLongOpt("checkmd5");
    checkMd5.setOptionalArg(true);
    checkMd5.setType(Boolean.class);
    checkMd5.setDescription(
            "compare uploaded/downloaded local file MD5 summary with the one of the remote entry.");
    options.addOption(checkMd5);

    // check force creation option
    Option forceCreation = OptionBuilder.create('F');
    forceCreation.setLongOpt("force");
    forceCreation.setOptionalArg(true);
    forceCreation.setType(Boolean.class);
    forceCreation.setDescription(
            "forces the creation of the remote entry when replace is selected and the entry doesn't exist.");
    options.addOption(forceCreation);

    // settings file option
    Option settings = OptionBuilder.create('C');
    settings.setLongOpt("configuration");
    settings.setArgs(1);
    settings.setArgName("path");
    settings.setType(String.class);
    settings.setDescription(String.format(
            "where path is the path of the configuration file. The default value is '%s' in the same directory.",
            CONFIGURATION_FILE));
    options.addOption(settings);

    // create folders tree option
    Option tree = OptionBuilder.create('t');
    tree.setLongOpt("tree");
    tree.setOptionalArg(true);
    tree.setType(Boolean.class);
    tree.setDescription("create remote folders tree if one or more remote folders are not found.");
    options.addOption(tree);
}