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:be.dnsbelgium.rdap.client.ManGenerator.java

public static void main(String[] args) {
    Options options = new RDAPOptions(Locale.ENGLISH);
    Iterator<Option> it = options.getOptions().iterator();
    StringBuilder sb = new StringBuilder();
    while (it.hasNext()) {
        Option option = it.next();
        sb.append(String.format(".IP \"%s\"\n%s\n", getOptionString(option),
                option.getDescription() == null ? "" : option.getDescription()));
    }//from w  w  w. ja  v  a 2s  .  c  o m
    System.out.println(sb.toString());
}

From source file:eu.edisonproject.utility.execute.Main.java

public static void main(String args[]) {
    Options options = new Options();
    Option operation = new Option("op", "operation", true,
            "type of operation to perform. " + "To move cached terms from org.mapdb.DB 'm'");
    operation.setRequired(true);//from   w  ww.  j av a 2  s.c  om
    options.addOption(operation);

    Option input = new Option("i", "input", true, "input file path");
    input.setRequired(true);
    options.addOption(input);

    String helpmasg = "Usage: \n";
    for (Object obj : options.getOptions()) {
        Option op = (Option) obj;
        helpmasg += op.getOpt() + ", " + op.getLongOpt() + "\t Required: " + op.isRequired() + "\t\t"
                + op.getDescription() + "\n";
    }

    try {
        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(options, args);

        switch (cmd.getOptionValue("operation")) {
        case "m":
            DBTools.portTermCache2Hbase(cmd.getOptionValue("input"));
            DBTools.portBabelNetCache2Hbase(cmd.getOptionValue("input"));
            break;
        default:
            System.out.println(helpmasg);
        }

    } catch (Exception ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, helpmasg, ex);
    }
}

From source file:net.kahowell.xsd.fuzzer.XmlGenerator.java

/**
 * Drives the application, parsing command-line arguments to determine
 * options./*from ww  w .j  a  v  a  2  s.c  o m*/
 * 
 * @param args command line args
 */
public static void main(String[] args) {
    try {
        setupLog4j();
        CommandLine commandLine = parser.parse(ConsoleOptions.OPTIONS, args);
        if (commandLine.hasOption("d")) {
            Logger.getLogger("net.kahowell.xsd.fuzzer").setLevel(Level.DEBUG);
        }
        for (Option option : commandLine.getOptions()) {
            if (option.getValue() != null) {
                log.debug("Using " + option.getDescription() + ": " + option.getValue());
            } else {
                log.debug("Using " + option.getDescription());
            }
        }

        Injector injector = Guice.createInjector(
                Modules.override(Modules.combine(new DefaultGeneratorsModule(), new DefaultOptionsModule()))
                        .with(new CommandLineArgumentsModule(commandLine)));

        log.debug(injector.getBindings());

        XsdParser xsdParser = injector.getInstance(XsdParser.class);
        XmlOptions xmlOptions = injector
                .getInstance(Key.get(XmlOptions.class, Names.named("xml save options")));
        XmlGenerator xmlGenerator = injector.getInstance(XmlGenerator.class);
        XmlGenerationOptions xmlGenerationOptions = injector.getInstance(XmlGenerationOptions.class);

        doPostModuleConfig(commandLine, xmlGenerationOptions, injector);

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        XmlObject generatedXml = xsdParser.generateXml(commandLine.getOptionValue("root"));
        generatedXml.save(stream, xmlOptions);
        if (commandLine.hasOption("v")) {
            if (xsdParser.validate(stream)) {
                log.info("Valid XML file produced.");
            } else {
                log.info("Invalid XML file produced.");
                System.exit(4);
            }
        }
        xmlGenerator.showOrSave(stream);
    } catch (MissingOptionException e) {
        if (e.getMissingOptions().size() != 0) {
            System.err.println("Missing argument(s): " + Arrays.toString(e.getMissingOptions().toArray()));
        }
        helpFormatter.printHelp(XmlGenerator.class.getSimpleName(), ConsoleOptions.OPTIONS);
        System.exit(1);
    } catch (ParseException e) {
        helpFormatter.printHelp(XmlGenerator.class.getSimpleName(), ConsoleOptions.OPTIONS);
        System.exit(2);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(3);
    }
}

From source file:eu.edisonproject.training.execute.Main.java

public static void main(String args[]) {
    Options options = new Options();
    Option operation = new Option("op", "operation", true,
            "type of operation to perform. " + "For term extraction use 'x'.\n"
                    + "Example: -op x -i E-COCO/documentation/sampleTextFiles/databases.txt "
                    + "-o E-COCO/documentation/sampleTextFiles/databaseTerms.csv"
                    + "For word sense disambiguation use 'w'.\n"
                    + "Example: -op w -i E-COCO/documentation/sampleTextFiles/databaseTerms.csv "
                    + "-o E-COCO/documentation/sampleTextFiles/databse.avro\n"
                    + "For tf-idf vector extraction use 't'.\n" + "For running the apriori algorithm use 'a'");
    operation.setRequired(true);//from  w  w  w.  j a  v a2s. c om
    options.addOption(operation);

    Option input = new Option("i", "input", true, "input file path");
    input.setRequired(true);
    options.addOption(input);

    Option output = new Option("o", "output", true, "output file");
    output.setRequired(true);
    options.addOption(output);

    Option popertiesFile = new Option("p", "properties", true, "path for a properties file");
    popertiesFile.setRequired(false);
    options.addOption(popertiesFile);

    Option termsFile = new Option("t", "terms", true, "terms file");
    termsFile.setRequired(false);
    options.addOption(termsFile);

    String helpmasg = "Usage: \n";
    for (Object obj : options.getOptions()) {
        Option op = (Option) obj;
        helpmasg += op.getOpt() + ", " + op.getLongOpt() + "\t Required: " + op.isRequired() + "\t\t"
                + op.getDescription() + "\n";
    }

    try {
        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(options, args);

        String propPath = cmd.getOptionValue("properties");
        if (propPath == null) {
            prop = ConfigHelper
                    .getProperties(".." + File.separator + "etc" + File.separator + "configure.properties");
        } else {
            prop = ConfigHelper.getProperties(propPath);
        }
        //            ${user.home}

        switch (cmd.getOptionValue("operation")) {
        case "x":
            termExtraction(cmd.getOptionValue("input"), cmd.getOptionValue("output"));
            break;
        case "w":
            wsd(cmd.getOptionValue("input"), cmd.getOptionValue("output"));
            break;
        case "t":
            calculateTFIDF(cmd.getOptionValue("input"), cmd.getOptionValue("output"));
            break;
        //                case "tt":
        //                    calculateTermTFIDF(cmd.getOptionValue("input"), cmd.getOptionValue("terms"), cmd.getOptionValue("output"));
        //                    break;
        case "a":
            apriori(cmd.getOptionValue("input"), cmd.getOptionValue("output"));
            break;
        default:
            System.out.println(helpmasg);
        }

    } catch (Exception ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, helpmasg, ex);
    }
}

From source file:maps.OptionsHandler.java

static private void printHelpOption() {
    System.out.println("Usage:");
    for (Option o : options.getOptions())
        System.out.println(String.format("\t-%s --%s\t%s", o.getOpt(), o.getLongOpt(), o.getDescription()));
    System.exit(0);//from w  w  w .j  a v  a2  s .c om
}

From source file:com.smartmarmot.dbforbix.DBforBix.java

private static void displayUsage() {
    System.out.println(Constants.BANNER);
    for (Option o : ((Collection<Option>) options.getOptions()))
        System.out.println("\t-" + o.getOpt() + "\t" + o.getDescription());
}

From source file:com.datastax.brisk.demo.pricer.Pricer.java

/**
 * Printing out help message/*from www . j  a va2  s . co  m*/
 */
public static void printHelpMessage() {
    System.out.println("Usage: ./bin/pricer [options]\n\nOptions:");

    for (Object o : Session.availableOptions.getOptions()) {
        Option option = (Option) o;
        String upperCaseName = option.getLongOpt().toUpperCase();
        System.out.println(String.format("-%s%s, --%s%s%n\t\t%s%n", option.getOpt(),
                (option.hasArg()) ? " " + upperCaseName : "", option.getLongOpt(),
                (option.hasArg()) ? "=" + upperCaseName : "", option.getDescription()));
    }
}

From source file:de.haber.xmind2latex.cli.CliParameters.java

/**
 * Helper method that throws a {@link ParseException} if parameter arguments are missing.
 * // w w w . j av  a  2s  . co  m
 * @param cmd the concrete {@link CommandLine}
 * @param param name of the parameter that is to be validated
 * @param opts configured {@link Options}
 * @throws ParseException if the number of arguments does not correspond to the expected number of arguments for the given parameter
 */
public static void validateNumberOfArguments(CommandLine cmd, char param, Options opts) throws ParseException {
    Integer numberOfArgs = param2arguments.get(param);
    String[] tmp = cmd.getOptionValues(param);
    if (numberOfArgs != null && tmp != null && tmp.length % numberOfArgs != 0) {
        Option o = opts.getOption(Character.toString(param));
        String name = o.getLongOpt() != null ? o.getLongOpt() : Character.toString(param);
        throw new ParseException("Invalid amount of arguments for parameter " + name + ": <" + o.getArgName()
                + ">. Description: " + o.getDescription());
    }
}

From source file:dk.hippogrif.prettyxml.app.Main.java

private static void optionUsage(PrintStream ps) {
    for (Iterator iter = optionList.iterator(); iter.hasNext();) {
        Option option = (Option) iter.next();
        ps.print("  -" + option.getOpt());
        String spaces = "              ";
        int i = 0;
        if (option.hasArg()) {
            ps.print(" " + option.getArgName());
            i = option.getArgName().length() + 1;
        }/*w  w w .  j a  v  a  2s .  c om*/
        ps.print(spaces.substring(i));
        ps.println(option.getDescription());
    }
}

From source file:EditBinFile.java

private static void printHelp(Options options) {

    Collection list = options.getOptions();
    Iterator iterator = list.iterator();

    // while loop
    String tmp = "";
    Option otmp;
    while (iterator.hasNext()) {
        otmp = (Option) iterator.next();
        System.out.println(String.format("%-15s %s", "-" + otmp.getOpt(), otmp.getDescription()));
    }// ww w  .  ja v  a2 s.com
}