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.esri.geoevent.test.performance.OrchestratorMain.java

private static void printHelp(Options testHarnessOptions) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setLongOptPrefix("-");
    formatter.setArgName("value");
    formatter.setWidth(100);
    // do not sort the options in any order
    formatter.setOptionComparator(new Comparator<Option>() {
        @Override/*w w w .  j a  v  a  2 s.  com*/
        public int compare(Option o1, Option o2) {
            return 0;
        }
    });

    formatter.printHelp(ImplMessages.getMessage("ORCHESTRATOR_EXECUTOR_HELP_TITLE_MSG"), testHarnessOptions,
            true);
    System.out.println("");

}

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

/**
 * Print_usage.//from www. j a  v a2  s. co  m
 *
 * @param options the options
 */
private static void print_usage(Options options) {
    // automatically generate the help statement
    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(90);
    formatter.printHelp("qufd", "QUFD maps a given QASM "
            + "to a supplied PMD fabric. The resultant MCL file of " + "the mapped circuit will be generated.",
            options, "", true);
}

From source file:com.asakusafw.windgate.bootstrap.WindGate.java

static int execute(String[] args) {
    try (SafeCloser<GateTask> closer = new SafeCloser<>()) {
        try {//from   ww  w . j a va  2 s .  co  m
            Configuration conf = parseConfiguration(args);
            closer.set(new GateTask(conf.profile, conf.script, conf.sessionId, conf.mode.createsSession,
                    conf.mode.completesSession, conf.arguments));
        } catch (Exception e) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.setWidth(Integer.MAX_VALUE);
            formatter.printHelp(MessageFormat.format("java -classpath ... {0}", WindGate.class.getName()),
                    OPTIONS, true);
            System.out.println("Note:");
            System.out.println("  Profile and script path accept following URI formats:");
            System.out.println("    no scheme -");
            System.out.println("      Local file system path");
            System.out.println("    \"classpath\" scheme -");
            System.out.println("      Absolute path on class path (includes plugin libraries)");
            System.out.println("    other schemes (e.g. http://...)-");
            System.out.println("      Processed as a URL");
            WGLOG.error(e, "E00001");
            return 1;
        }
        GateTask task = closer.get();
        if (RuntimeContext.get().canExecute(task)) {
            task.execute();
        }
        return 0;
    } catch (Exception e) {
        WGLOG.error(e, "E00002");
        return 1;
    }
}

From source file:com.leshazlewood.scms.cli.Main.java

private static void printHelp(Options options, Exception e, boolean debug) {
    HelpFormatter help = new HelpFormatter();
    help.setWidth(80);
    String command = "scms [options] [src_dir] dest_dir";
    String header = "Injests content files in [src dir] and renders a static website into dest_dir.\n\n"
            + "  [src_dir] is optional and defaults to the current working directory.\n"
            + "  dest_dir is required and cannot be the same as src_dir.";
    /*String footer = "\n" +
        "Injests source content files and page templates in [src dir] and renders a\n" +
        "renders a static website into destination_directory.\n\n" +
        "If unspecified, [source directory] defaults to the current working\n" +
        "directory.  destination_directory is required and cannot be the same\n" +
        "as the source directory.";*/

    printException(e, debug);//  ww w . ja  va2  s  . com

    System.out.println();

    System.out.println("Usage:");
    System.out.print("  ");
    System.out.println(command);
    System.out.println();
    System.out.println("Description:");
    System.out.print("  ");
    System.out.println(header);
    System.out.println();
    System.out.println("Options:");

    StringBuilder sb = new StringBuilder();

    int columnWidth = calculateColumnWidth(options);

    for (Object o : options.getOptions()) {
        Option option = (Option) o;
        StringBuilder csb = new StringBuilder("  ");
        csb.append("-").append(option.getOpt()).append(",--").append(option.getLongOpt());
        if (option.hasArg()) {
            csb.append(" <arg>");
        }
        int csbLength = csb.length();
        for (int i = 0; i < (columnWidth - csbLength); i++) {
            csb.append(" ");
        }
        sb.append(csb.toString()).append("   ").append(option.getDescription()).append("\n");
    }
    System.out.println(sb);

    //help.printHelp("", "", options, null);
    //System.out.println(footer);
}

From source file:com.google.flightmap.parsing.faa.nasr.CommParser.java

private static void printHelp(final CommandLine line) {
    final HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(100);
    formatter.printHelp("CommParser", OPTIONS, true);
}

From source file:com.asakusafw.directio.hive.tools.cli.GenerateCreateTable.java

static int execute(String... args) {
    GenerateCreateTableTask task = new GenerateCreateTableTask();
    GenerateCreateTableTask.Configuration conf;
    try {/*w  ww.  j av  a 2s.  c  o m*/
        conf = parseConfiguration(args);
    } catch (Exception e) {
        LOG.error(Messages.getString("GenerateCreateTable.errorInvalidArgument"), e); //$NON-NLS-1$
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(Integer.MAX_VALUE);
        formatter.printHelp(MessageFormat.format("java -classpath ... {0}", //$NON-NLS-1$
                GenerateCreateTable.class.getName()), OPTIONS, true);
        return 1;
    }
    try {
        task.perform(conf);
    } catch (Exception e) {
        LOG.error(Messages.getString("GenerateCreateTable.errorExecute"), e); //$NON-NLS-1$
        return 1;
    } finally {
        closeQuiet(conf.classLoader);
    }
    return 0;
}

From source file:com.emc.ecs.EcsBufferedWriter.java

protected static void help() {
    HelpFormatter fmt = new HelpFormatter();
    fmt.setWidth(79);

    Options options = options();/*from w w  w  .j a va2  s. c om*/
    fmt.printHelp("java -jar ECSWriter.jar (write|append|tail) [options]\n" + "options:", options);
}

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

/**
 * Program entry./*w w  w.j av  a  2  s .  co m*/
 * @param args program arguments
 * @return the exit code
 */
public static int execute(String[] args) {
    Conf conf;
    try {
        conf = 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("BatchTestTruncator.errorInvalidArgument"), //$NON-NLS-1$
                Arrays.toString(args)), e);
        return 1;
    }
    try {
        BatchTestTruncator truncator = new BatchTestTruncator(conf.context);
        for (ImporterDescription desc : conf.importers) {
            truncator.truncate(desc);
        }
        for (ExporterDescription desc : conf.exporters) {
            truncator.truncate(desc);
        }
        return 0;
    } catch (Exception e) {
        LOG.error(MessageFormat.format(Messages.getString("BatchTestTruncator.errorFailedToTruncate"), //$NON-NLS-1$
                Arrays.toString(args)), e);
        return 1;
    }
}

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

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

From source file:com.esri.geoevent.test.performance.ConsumerMain.java

private static void printHelp(Options performerOptions) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setLongOptPrefix("-");
    formatter.setArgName("value");
    formatter.setWidth(100);
    // do not sort the options in any order
    formatter.setOptionComparator(new Comparator<Option>() {
        @Override//from   ww  w.  j  ava2 s  .  c o  m
        public int compare(Option o1, Option o2) {
            return 0;
        }
    });

    formatter.printHelp(ImplMessages.getMessage("CONSUMER_EXECUTOR_HELP_TITLE_MSG"), performerOptions, true);
    System.out.println("");
}