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

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

Introduction

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

Prototype

public String getDescription() 

Source Link

Document

Retrieve the self-documenting description of this Option

Usage

From source file:org.g_node.srv.CliOptionServiceTest.java

/**
 * Main assertions of all option arguments.
 * @param opt The actual {@link Option}.
 * @param shortOpt Short commandline argument of the current option.
 * @param longOpt Long commandline argument of the current option.
 * @param desc Description text of the current option.
 * @param isRequired Whether the current option is a required commandline argument.
 * @param hasArguments Whether the current option requires an additional argument.
 *///from ww w . j  a  va  2 s .  c  o m
private void assertOption(final Option opt, final String shortOpt, final String longOpt, final String desc,
        final Boolean isRequired, final Boolean hasArgument, final Boolean hasArguments) {
    assertThat(opt.getOpt()).isEqualToIgnoringCase(shortOpt);
    assertThat(opt.getLongOpt()).isEqualToIgnoringCase(longOpt);
    assertThat(opt.getDescription()).contains(desc);
    assertThat(opt.isRequired()).isEqualTo(isRequired);
    assertThat(opt.hasArg()).isEqualTo(hasArgument);
    assertThat(opt.hasArgs()).isEqualTo(hasArguments);
}

From source file:org.jgap.util.SystemKit.java

/**
 * Prints all available comamnd line options.
 *
 * @param cmd the CommandLine object//from  w  w w.ja  va 2  s .c  om
 * @param options the Options list
 *
 * @author Klaus Meffert
 * @since 3.3.4
 */
public static void printHelp(CommandLine cmd, Options options) {
    if (cmd.hasOption("help")) {
        System.out.println("");
        System.out.println(" Command line options:");
        System.out.println(" ---------------------");
        for (Object opt0 : options.getOptions()) {
            Option opt = (Option) opt0;
            String s = opt.getOpt();
            s = StringKit.fill(s, 20, ' ');
            System.out.println(" " + s + " - " + opt.getDescription());
        }
        System.exit(0);
    }
}

From source file:org.kyupi.apps.App.java

protected void printOptionHelp() {
    for (Object oo : options.getOptions()) {
        Option op = (Option) oo;
        log.info("  -" + op.getOpt() + "\t" + op.getDescription());
    }//from  w ww  . j a v a 2 s .  c  o  m
}

From source file:org.pz.platypus.commandline.ClParser.java

/**
 * Return all possible options as a sorted TreeMap of option, description
 *///from  w  ww.  j  a v a 2s.c o  m
public TreeMap<String, String> getAllOptions() {
    ClOptions clo = new ClOptions();
    TreeMap<String, String> optionsWithDesc = new TreeMap<String, String>();
    for (Option o : clo.getOptions()) {
        optionsWithDesc.put("-" + o.getOpt() + (o.hasArg() ? (" [" + o.getArgName() + "]") : ""),
                o.getDescription());
    }
    return (optionsWithDesc);
}

From source file:org.zend.sdkcli.internal.commands.UsageCommand.java

private void printCommandUsage() {
    System.out.println("Usage:");
    System.out.println("  zend action [action options] [global options]");
    System.out.println();/*  ww  w.j a va2  s. c  om*/
    System.out.println("Global options:");

    final Options options = new Options();
    DetectOptionUtility.addOption(AbstractCommand.class, options, false);

    for (Object obj : options.getOptions()) {
        Option o = (Option) obj;
        System.out.printf("  -%-3s %s\n", o.getOpt(), o.getDescription());
    }
    System.out.println();
    System.out.println("Valid actions are composed of a verb and an optional direct object:");
}

From source file:org.zend.sdkcli.internal.commands.UsageCommand.java

private void printCommandOptions(CommandType type) {
    Options opts = new Options();
    System.out.println();/*  w  w  w . ja  v a2s  . co  m*/

    // get command specific options
    DetectOptionUtility.addOption(CommandFactory.createCommand(type).getClass(), opts, true);

    if (opts.getOptions().size() > 0) {
        System.out.println("Options:");
        Collection collection = opts.getOptions();
        for (Object o : collection) {
            Option opt = (Option) o;
            System.out.printf("  -%-3s %s%s\n", opt.getOpt(), opt.getDescription(),
                    opt.isRequired() ? " [required]" : "");
        }
    } else {
        System.out.println("  No options");
    }

    System.out.println();
}

From source file:oxis.yologp.CommandLineMain.java

public void printHelp() {

    for (Object obj : options.getOptions().toArray(new Option[0])) {
        Option opt = (Option) obj;
        System.out.println(//from   w w  w.  ja  va  2 s  . co  m
                String.format("  -%s|--%-30s ", opt.getOpt(), opt.getLongOpt()) + opt.getDescription());
    }
    System.exit(0);
}

From source file:treecmp.commandline.CommandLineParser.java

private static void printOptionsInEffect(String analysisType, ActiveMetricsSet AMSet, String inputFileName,
        String outputFileName, List<Option> custOpts) {
    System.out.print(OPTS_HEADER);
    System.out.print(OPTS_TYPE + analysisType + "\n");
    System.out.print(OPTS_METRICS);
    Metric[] metrics = AMSet.getActiveMetricsTable();
    int nr;//  www .  j  a v a 2  s .  co m
    Metric m;
    for (int i = 0; i < metrics.length; i++) {
        m = metrics[i];
        nr = i + 1;
        System.out.print("  " + nr + ". " + m.getName() + " (" + m.getCommandLineName() + ")\n");
    }

    System.out.print(OPTS_INPUT + inputFileName + "\n");
    System.out.print(OPTS_OUTPUT + outputFileName + "\n");
    if (!custOpts.isEmpty()) {
        System.out.print(OPTS_CUSTOM);
        for (Option opt : custOpts) {
            String optMsg = opt.getOpt() + " " + opt.getDescription() + "\n";
            System.out.print(optMsg);
        }
    }
    System.out.print("-----\n");

}

From source file:uk.ac.ebi.mdk.apps.CommandLineMain.java

public void showHelp() {
    for (Object obj : toArray(new Option[0])) {
        Option opt = (Option) obj;
        System.out.println(String.format("    [%s|%s]\n        %s \n", opt.getOpt(), opt.getLongOpt(),
                opt.getDescription()));
    }//from   ww  w  .  j ava2  s. c o m
    System.exit(0);
}