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.genentech.chemistry.tool.align.SDFAlign.java

private static void exitWithHelp(String msg, Options options) {
    System.err.println(msg);/*from  w  w  w  .j a v a  2s . co m*/

    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(120);
    formatter.printHelp("sdfAlign -in .sdf -out .sdf [-ref .sdf]", options);
    System.exit(1);
}

From source file:com.opengamma.bloombergexample.loader.PortfolioLoaderHelper.java

public static void usage(String loaderName) {
    HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.setWidth(100);
    helpFormatter.printHelp(loaderName, OPTIONS);
}

From source file:com.asakusafw.testdata.generator.excel.Main.java

static int start(String... args) {
    assert args != null;
    GenerateTask task;/*from  w  w w  .  ja v  a  2  s . c  o  m*/
    try {
        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(OPTIONS, args);
        TemplateGenerator generator = getGenerator(cmd);
        DmdlSourceRepository repository = getRepository(cmd);
        ClassLoader classLoader = getClassLoader(cmd);
        task = new GenerateTask(generator, repository, classLoader);
    } catch (Exception e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(Integer.MAX_VALUE);
        formatter.printHelp(MessageFormat.format("java -classpath ... {0}", //$NON-NLS-1$
                Main.class.getName()), OPTIONS, true);
        System.out.printf(Messages.getString("Main.helpFormatHead"), OPT_FORMAT.getOpt()); //$NON-NLS-1$
        System.out.printf(" %8s - %s%n", WorkbookFormat.DATA, //$NON-NLS-1$
                Messages.getString("Main.helpFormatData")); //$NON-NLS-1$
        System.out.printf(" %8s - %s%n", WorkbookFormat.RULE, //$NON-NLS-1$
                Messages.getString("Main.helpFormatRule")); //$NON-NLS-1$
        System.out.printf(" %8s - %s%n", WorkbookFormat.INOUT, //$NON-NLS-1$
                Messages.getString("Main.helpFormatInout")); //$NON-NLS-1$
        System.out.printf(" %8s - %s%n", WorkbookFormat.INSPECT, //$NON-NLS-1$
                Messages.getString("Main.helpFormatInspect")); //$NON-NLS-1$
        System.out.printf(" %8s - %s%n", WorkbookFormat.ALL, //$NON-NLS-1$
                Messages.getString("Main.helpFormatAll")); //$NON-NLS-1$
        System.out.printf(" %8s - %s%n", WorkbookFormat.DATAX, //$NON-NLS-1$
                Messages.getString("Main.helpFormatDataX")); //$NON-NLS-1$
        System.out.printf(" %8s - %s%n", WorkbookFormat.RULEX, //$NON-NLS-1$
                Messages.getString("Main.helpFormatRuleX")); //$NON-NLS-1$
        System.out.printf(" %8s - %s%n", WorkbookFormat.INOUTX, //$NON-NLS-1$
                Messages.getString("Main.helpFormatInoutX")); //$NON-NLS-1$
        System.out.printf(" %8s - %s%n", WorkbookFormat.INSPECTX, //$NON-NLS-1$
                Messages.getString("Main.helpFormatInspectX")); //$NON-NLS-1$
        System.out.printf(" %8s - %s%n", WorkbookFormat.ALLX, //$NON-NLS-1$
                Messages.getString("Main.helpFormatAllX")); //$NON-NLS-1$
        e.printStackTrace(System.out);
        return 1;
    }
    try {
        task.process();
    } catch (IOException e) {
        e.printStackTrace(System.out);
        return 1;
    }
    return 0;
}

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

/**
 * Program entry.//from w ww  . ja  va 2  s . c  om
 * @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("BatchTestVerifier.errorInvalidArgument"), //$NON-NLS-1$
                Arrays.toString(args)), e);
        return 1;
    }
    try {
        BatchTestVerifier verifier = new BatchTestVerifier(conf.context);
        List<Difference> diffList = verifier.verify(conf.exporter, conf.data, conf.rule);
        if (diffList.isEmpty()) {
            LOG.info(Messages.getString("BatchTestVerifier.infoSuccess")); //$NON-NLS-1$
            return 0;
        } else {
            for (Difference diff : diffList) {
                LOG.error(diff.toString());
            }
            return 1;
        }
    } catch (Exception e) {
        LOG.error(MessageFormat.format(Messages.getString("BatchTestVerifier.errorFailedToVerifyResult"), //$NON-NLS-1$
                Arrays.toString(args)), e);
        return 1;
    }
}

From source file:com.linkedin.helix.controller.HelixControllerMain.java

public static void printUsage(Options cliOptions) {
    HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.setWidth(1000);
    helpFormatter.printHelp("java " + HelixControllerMain.class.getName(), cliOptions);
}

From source file:com.emc.ecs.sync.cli.CliHelper.java

public static String longHelp() {
    StringWriter helpWriter = new StringWriter();
    PrintWriter pw = new PrintWriter(helpWriter);
    HelpFormatter fmt = new HelpFormatter();
    fmt.setWidth(79);

    // main CLI options
    Options options = ConfigUtil.wrapperFor(CliConfig.class).getOptions();

    // sync options
    for (Option o : ConfigUtil.wrapperFor(SyncOptions.class).getOptions().getOptions()) {
        options.addOption(o);// w w  w .  jav a2s  . c om
    }

    // Make sure we do CommonOptions first
    String usage = "java -jar ecs-sync.jar -source <source-uri> [-filters <filter1>[,<filter2>,...]] -target <target-uri> [options]";
    fmt.printHelp(pw, fmt.getWidth(), usage, "Common options:", options, fmt.getLeftPadding(),
            fmt.getDescPadding(), null);

    pw.print("\nAvailable plugins are listed below along with any custom options they may have\n");

    // Do the rest
    for (ConfigWrapper<?> storageWrapper : ConfigUtil.allStorageConfigWrappers()) {
        pw.write('\n');
        pw.write(String.format("%s (%s)\n", storageWrapper.getLabel(), storageWrapper.getUriPrefix()));
        fmt.printWrapped(pw, fmt.getWidth(), 4, "    " + storageWrapper.getDocumentation());
        fmt.printWrapped(pw, fmt.getWidth(), 4,
                "    NOTE: Storage options must be prefixed by source- or target-, depending on which role they assume");
        fmt.printOptions(pw, fmt.getWidth(), storageWrapper.getOptions(), fmt.getLeftPadding(),
                fmt.getDescPadding());
    }
    for (ConfigWrapper<?> filterWrapper : ConfigUtil.allFilterConfigWrappers()) {
        pw.write('\n');
        pw.write(String.format("%s (%s)\n", filterWrapper.getLabel(), filterWrapper.getCliName()));
        fmt.printWrapped(pw, fmt.getWidth(), 4, "    " + filterWrapper.getDocumentation());
        fmt.printOptions(pw, fmt.getWidth(), filterWrapper.getOptions(), fmt.getLeftPadding(),
                fmt.getDescPadding());
    }

    return helpWriter.toString();
}

From source file:com.google.flightmap.parsing.faa.nfd.tools.RecordStructGenerator.java

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

From source file:lunarion.cluster.quickstart.ExampleProcess.java

public static void printUsage(Options cliOptions) {
    HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.setWidth(1000);
    helpFormatter.printHelp("java " + ExampleProcess.class.getName(), cliOptions);
}

From source file:com.google.flightmap.parsing.faa.afd.AfdCommParser.java

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

From source file:com.asakusafw.yaess.tools.log.cli.Main.java

/**
 * Program entry./* ww  w  . j a v  a 2  s  . c  o  m*/
 * @param args program arguments
 * @return exit code
 */
public static int execute(String[] args) {
    Configuration conf;
    try {
        conf = parseConfiguration(args);
    } catch (Exception e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(Integer.MAX_VALUE);
        formatter.printHelp(MessageFormat.format("java -classpath ... {0}", Main.class.getName()), OPTIONS,
                true);
        LOG.error(MessageFormat.format("Invalid program arguments: {0}", Arrays.toString(args)), e);
        return 2;
    }
    try {
        execute(conf);
    } catch (IllegalArgumentException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(Integer.MAX_VALUE);
        formatter.printHelp(MessageFormat.format("java -classpath ... {0}", Main.class.getName()), OPTIONS,
                true);
        System.out.println("Input Driver Arguments:");
        printArguments(conf.sourceFactory.getOptionsInformation());
        System.out.println("Output Driver Arguments:");
        printArguments(conf.sinkFactory.getOptionsInformation());
        LOG.error(MessageFormat.format("Invalid driver arguments: {0}", Arrays.toString(args)), e);
        return 2;
    } catch (Exception e) {
        LOG.error(MessageFormat.format("Failed to analyze YAESS log: {0}", Arrays.toString(args)), e);
        return 1;
    }
    return 0;
}