Example usage for org.apache.commons.cli HelpFormatter setWidth

List of usage examples for org.apache.commons.cli HelpFormatter setWidth

Introduction

In this page you can find the example usage for org.apache.commons.cli HelpFormatter setWidth.

Prototype

public void setWidth(int width) 

Source Link

Document

Sets the 'width'.

Usage

From source file:com.google.api.ads.adwords.awreporting.server.AwReportingServer.java

/**
 * Prints the help message./* w w w .  ja  va  2s  . c o  m*/
 *
 * @param options the options available for the user.
 */
private static void printHelpMessage(Options options) {

    // automatically generate the help statement
    System.out.println();
    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(120);

    formatter.printHelp(
            "java -Xmx4G -jar aw-reporting-server.jar -startDate YYYYMMDD -endDate YYYYMMDD -file <file>\n"
                    + "-Xmx4G -jar aw-reporting-server.jar -processKratus -startDate YYYYMMDD -endDate YYYYMMDD -file <file>\n"
                    + "-Xmx4G -jar aw-reporting-server.jar -startServer -file <file>\n",
            options);

    printSamplePropertiesFile();
    System.out.println();
}

From source file:com.asakusafw.testdriver.tools.runner.BatchTestRunner.java

/**
 * Program entry.//from  ww w. j av  a 2 s  .  c  o m
 * @param args program arguments
 * @return the exit code
 * @see #execute(String, Map)
 */
public static int execute(String[] args) {
    BatchTestRunner runner;
    try {
        runner = parseArguments(args);
    } catch (Exception e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(Integer.MAX_VALUE);
        formatter.printHelp(MessageFormat.format("java -classpath ... {0}", //$NON-NLS-1$
                BatchTestRunner.class.getName()), OPTIONS, true);
        LOG.error(MessageFormat.format(Messages.getString("BatchTestRunner.errorInvalidArgument"), //$NON-NLS-1$
                Arrays.toString(args)), e);
        return 1;
    }
    return runner.execute();
}

From source file:edu.cmu.tetrad.cli.util.Args.java

public static void showHelp(String algorithmName, Options options) {
    StringBuilder sb = new StringBuilder("java -jar");
    try {/*from ww  w . j  av a2  s  . c  o m*/
        JarFile jarFile = new JarFile(Args.class.getProtectionDomain().getCodeSource().getLocation().getPath(),
                true);
        Manifest manifest = jarFile.getManifest();
        Attributes attributes = manifest.getMainAttributes();
        String artifactId = attributes.getValue("Implementation-Title");
        String version = attributes.getValue("Implementation-Version");
        sb.append(String.format(" %s-%s.jar", artifactId, version));
    } catch (IOException exception) {
        sb.append(" causal-cmd.jar");
    }
    sb.append(" --algorithm ");
    sb.append(algorithmName);

    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(-1);
    formatter.printHelp(sb.toString(), options, true);
}

From source file:edu.usc.squash.Main.java

private static void print_usage(Options options) {
    // automatically generate the help statement
    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(90);
    formatter.printHelp("squash", "Squash v2: A hierarchical scalable considering ancilla sharing", options, "",
            true);// w w w.j a  v a2  s .co m
}

From source file:com.continuent.tungsten.common.security.PasswordManagerCtrl.java

/**
 * Display the program help and exits//ww  w.j a  v  a2  s .co m
 */
private static void DisplayHelpAndExit(EXIT_CODE exitCode) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(120);
    formatter.printHelp("tpasswd", pwd.options);
    Exit(exitCode);
}

From source file:com.linkedin.databus2.client.util.CheckpointSerializerMain.java

private static void printCliHelp(Options cliOptions) {
    HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.setWidth(120);
    helpFormatter.printHelp("java " + CheckpointSerializerMain.class.getName(), cliOptions);
}

From source file:autocorrelator.apps.SDFGroovy.java

private static void exitWithHelp(String msg, Options options) {
    System.err.println(msg);//from  www.  j  av a 2  s  .  c o m
    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(120);
    formatter.printHelp(INTROText, options);

    StringBuilder sb = new StringBuilder();
    Class<SDFGroovyHelper> helper = SDFGroovyHelper.class;
    for (Method m : helper.getMethods()) {
        if ((m.getModifiers() & Modifier.STATIC) == 0 || (m.getModifiers() & Modifier.PUBLIC) == 0)
            continue;

        String meth = m.toString();
        meth = meth.replaceAll("public static final ", "");
        meth = meth.replaceAll("java\\.lang\\.", "");
        meth = meth.replaceAll("java\\.math\\.", "");
        meth = meth.replaceAll("autocorrelator\\.apps\\.SDFGroovyHelper.", "");
        sb.append('\t').append(meth).append('\n');
    }
    System.out.println("Imported internal functions:");
    System.out.println(sb);
    System.exit(1);

}

From source file:de.pixida.logtest.buildserver.RunIntegrationTests.java

private static void printHelp(final Options options) {
    final HelpFormatter formatter = new HelpFormatter();
    final int assumedConsoleWidth = 150;
    formatter.setWidth(assumedConsoleWidth);
    formatter.printHelp("java -jar logtest-buildserver-app.jar [OPTIONS]... [EXECUTIONS]...\n"
            + "An EXECUTION is a triple <scenario-filename>:<automaton-filename>[:<parameters, comma separated key=value pairs...>,<...>]"
            + " e.g. tracelog.txt:checkSystemStartupSucceeds.json:waitForNetIO=yes,timeout=30" + "\n", // Separate help text from description of parameters with an empty line
            options);//from w w  w .  ja va  2 s .  co m
}

From source file:com.phonytive.astive.server.AstiveServer.java

private static void printUsage(AdminCommand ac, Options options) {
    String command = ac.getCommand();
    HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.setWidth(80);
    helpFormatter.printHelp(AppLocale.getI18n("cli." + command + ".usage"), AppLocale.getI18n("cli.header"),
            options, AppLocale.getI18n("cli.footer"));
}

From source file:edu.usc.qspr.Main.java

/**
 * Parses the inputs./* w  w w  . j ava 2 s .  c om*/
 *
 * @param args the args
 */
@SuppressWarnings("static-access")
public static void parseInputs(String[] args) {
    Options options = new Options();

    options.addOption(OptionBuilder.withLongOpt("input").withDescription("QASM input file").hasArg()
            .withArgName("file").create("i"));

    options.addOption(OptionBuilder.withLongOpt("fabric").withDescription("Fabric specification").hasArg()
            .withArgName("file").create("f"));

    options.addOption(OptionBuilder.withLongOpt("output").withDescription("Quantum operation output file")
            .hasArg().withArgName("file").create("o"));

    options.addOption(OptionBuilder.withLongOpt("placement")
            .withDescription("Select a placement technique from {MVFB, MC, Center, and Baseline}.").hasArg()
            .withArgName("method").create("p"));

    options.addOption(OptionBuilder.withLongOpt("seed").withDescription("Random seed count").hasArg()
            .withArgName("#").create("s"));

    options.addOption(OptionBuilder.withLongOpt("verbose")
            .withDescription("Verbosely prints the quantum operations").create("v"));

    options.addOption(OptionBuilder.withLongOpt("debug").withDescription("Print debugging info").create("d"));

    CommandLineParser parser = new GnuParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        System.exit(-1);
    }

    if (!cmd.hasOption("input") || !cmd.hasOption("fabric") || !cmd.hasOption("placement")) {
        // automatically generate the help statement
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(80);
        formatter.printHelp("qspr", "QSPR maps a given QASM "
                + "to a given PMD fabric. The resultant MCL file of " + "the mapped circuit will be generated.",
                options, "", true);

        System.exit(-1);
    }

    qasmFileAddr = cmd.getOptionValue("input");
    if (!new File(qasmFileAddr).exists()) {
        System.err.println("QASM file " + qasmFileAddr + " does not exist.");
        System.exit(-1);
    }

    fabricFileAddr = cmd.getOptionValue("fabric");
    if (!new File(fabricFileAddr).exists()) {
        System.err.println("Fabric file " + fabricFileAddr + " does not exist.");
        System.exit(-1);
    }

    placementMethod = cmd.getOptionValue("placement").toLowerCase();
    if (placementMethod.compareTo("mvfb") != 0 && placementMethod.compareTo("mc") != 0
            && placementMethod.compareTo("center") != 0 && placementMethod.compareTo("baseline") != 0) {
        System.err.println("Placement technique " + cmd.getOptionValue("placement")
                + " is not supported. Select from {MVFB, MC, Center, and Baseline}.");
        System.exit(-1);
    }

    if (placementMethod.compareTo("mvfb") == 0 || placementMethod.compareTo("mc") == 0) {
        if (!cmd.hasOption("seed")) {
            System.err.println("Number of random placements (seed #) is not specified.");
            System.exit(-1);
        } else {
            try {
                m = Integer.parseInt(placementMethod = cmd.getOptionValue("seed"));
            } catch (Exception e) {
                System.err.println("Seed \"" + cmd.getOptionValue("seed")
                        + "\" does not have a proper format. It should be an interger.");
                System.exit(-1);
            }
        }
    }

    if (cmd.hasOption("debug")) {
        RuntimeConfig.DEBUG = true;
    } else {
        RuntimeConfig.DEBUG = false;
    }

    if (cmd.hasOption("verbose")) {
        RuntimeConfig.VERBOSE = true;
    } else {
        RuntimeConfig.VERBOSE = false;
    }

    if (cmd.hasOption("output")) {
        RuntimeConfig.VERBOSE = true;
        RuntimeConfig.OUTPUT_TO_FILE = true;
        outputFileAddr = cmd.getOptionValue("output");
    } else {
        RuntimeConfig.OUTPUT_TO_FILE = false;
    }

}