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.asakusafw.yaess.bootstrap.Yaess.java

static int execute(String[] args) {
    assert args != null;
    Configuration conf;//from w  ww .j a  v a  2 s  .co m
    try {
        conf = parseConfiguration(args);
    } catch (Exception e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(Integer.MAX_VALUE);
        formatter.printHelp(MessageFormat.format("java -classpath ... {0}", Yaess.class.getName()), OPTIONS,
                true);
        System.out.println("Phase name is one of:");
        for (ExecutionPhase phase : ExecutionPhase.values()) {
            System.out.printf("    %s%n", phase.getSymbol());
        }
        YSLOG.error(e, "E00001", Arrays.toString(args));
        return 1;
    }
    try {
        ExecutionTask task;
        try {
            Map<String, Blob> blobs = new LinkedHashMap<>();
            for (Extension extension : conf.extensions) {
                blobs.put(extension.getName(), extension.getData());
            }
            task = ExecutionTask.load(conf.profile, conf.script, conf.arguments, conf.definitions, blobs);
        } catch (Exception e) {
            YSLOG.error(e, "E00002", conf);
            return 1;
        }
        YSLOG.info("I00001", conf);
        switch (conf.mode) {
        case BATCH:
            task.executeBatch(conf.batchId);
            break;
        case FLOW:
            task.executeFlow(conf.batchId, conf.flowId, conf.executionId);
            break;
        case PHASE:
            task.executePhase(conf.batchId, conf.flowId, conf.executionId, conf.phase);
            break;
        default:
            throw new AssertionError(conf.mode);
        }
        return 0;
    } catch (ExitCodeException e) {
        YSLOG.error("E00003", conf);
        return 1;
    } catch (Exception e) {
        YSLOG.error(e, "E00003", conf);
        return 1;
    } finally {
        for (Extension ext : conf.extensions) {
            try {
                ext.close();
            } catch (IOException e) {
                LOG.debug("error occurred while closing extension: {}", ext, e); //$NON-NLS-1$
            }
        }
    }
}

From source file:com.google.api.ads.adwords.jaxws.extensions.AwReporting.java

/**
 * Prints the help message./*from   www .j a va  2  s  .  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 -Xmx1G -jar aw-reporting.jar -startDate YYYYMMDD -endDate YYYYMMDD "
            + "-file <file>\n java -Xmx1G -jar aw-reporting.jar "
            + "-generatePdf <htmlTemplateFile> <outputDirectory> -startDate YYYYMMDD -endDate YYYYMMDD -file <file>",
            "\nArguments:", options, "");
    System.out.println();
}

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

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

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

/**
 * Prints the help message./*from   ww w.j ava2  s .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 -Xmx1G -jar aw-reporting.jar -startDate YYYYMMDD -endDate YYYYMMDD " + "-file <file>\n",
            "Arguments:", options, "");
    System.out.println();
}

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

private static void printUsage(AdminCommand ac, Options options) {
    String command = ac.getCommand();
    // capitalize command
    command = Character.toUpperCase(command.charAt(0)) + command.substring(1);
    HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.setWidth(80);
    helpFormatter.printHelp(AppLocale.getI18n("command" + command + "Usage"), AppLocale.getI18n("cliHeader"),
            options, AppLocale.getI18n("cliFooter"));
}

From source file:co.cask.cdap.data.tools.ReplicationStatusTool.java

private static void printUsage() {
    HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.setWidth(80);
    String usageHeader = "Options:";
    String usageFooter = "";
    String usageStr = "cdap run " + ReplicationStatusTool.class + " <options>";
    helpFormatter.printHelp(usageStr, usageHeader, options, usageFooter);
}

From source file:com.alibaba.rocketmq.common.MixAll.java

public static void printCommandLineHelp(final String appName, final Options options) {
    HelpFormatter hf = new HelpFormatter();
    hf.setWidth(110);
    hf.printHelp(appName, options, true);
}

From source file:com.alibaba.rocketmq.common.MixAll.java

public static CommandLine parseCmdLine(final String appName, String[] args, Options options,
        CommandLineParser parser) {/*from w ww.  j  av a2  s.c om*/
    HelpFormatter hf = new HelpFormatter();
    hf.setWidth(110);
    CommandLine commandLine = null;
    try {
        commandLine = parser.parse(options, args);
        if (commandLine.hasOption('h')) {
            hf.printHelp(appName, options, true);
            return null;
        }
    } catch (ParseException e) {
        hf.printHelp(appName, options, true);
    }

    return commandLine;
}

From source file:com.google.flightmap.parsing.faa.amr.AviationMasterRecordParser.java

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

From source file:brut.apktool.Main.java

private static void usage(CommandLine commandLine) {

    // load basicOptions
    _Options();//from  w  ww  . j a v a2 s  .  c  o  m
    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(120);

    // print out license info prior to formatter.
    System.out.println("Apktool v" + Androlib.getVersion() + " - a tool for reengineering Android apk files\n"
            + "with smali v" + ApktoolProperties.get("smaliVersion") + " and baksmali v"
            + ApktoolProperties.get("baksmaliVersion") + "\n"
            + "Copyright 2014 Ryszard Winiewski <brut.alll@gmail.com>\n"
            + "Updated by Connor Tumbleson <connor.tumbleson@gmail.com>");
    if (isAdvanceMode()) {
        System.out.println("Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)\n");
    } else {
        System.out.println("");
    }

    // 4 usage outputs (general, frameworks, decode, build)
    formatter.printHelp("apktool " + verbosityHelp(), normalOptions);
    formatter.printHelp("apktool " + verbosityHelp() + "if|install-framework [options] <framework.apk>",
            frameOptions);
    formatter.printHelp("apktool " + verbosityHelp() + "d[ecode] [options] <file_apk>", DecodeOptions);
    formatter.printHelp("apktool " + verbosityHelp() + "b[uild] [options] <app_path>", BuildOptions);
    if (isAdvanceMode()) {
        formatter.printHelp("apktool " + verbosityHelp() + "publicize-resources <file_path>",
                "Make all framework resources public.", emptyOptions, null);
    } else {
        System.out.println("");
    }

    // print out more information
    System.out.println("For additional info, see: http://ibotpeaches.github.io/Apktool/ \n"
            + "For smali/baksmali info, see: https://github.com/JesusFreke/smali");
}