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

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

Introduction

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

Prototype

public void setLeftPadding(int padding) 

Source Link

Document

Sets the 'leftPadding'.

Usage

From source file:io.github.felsenhower.stine_calendar_bot.main.CallLevelWrapper.java

/**
 * Prints the help screen for the current Options instance and exits the
 * application/*  ww w. jav a  2 s. c  o m*/
 */
private void printHelp() {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setOptionComparator(null);
    formatter.setDescPadding(4);
    formatter.setLeftPadding(2);
    formatter.setLongOptSeparator("=");
    formatter.setLongOptPrefix(" --");
    formatter.setSyntaxPrefix(cliStrings.get("Usage"));
    formatter.printHelp(cliStrings.get("UsageTemplate", appInfo.get("Name")),
            cliStrings.get("HelpHeader", appInfo.get("Name"), appInfo.get("Version")), this.options,
            cliStrings.get("HelpFooter", cliStrings.get("Author"), cliStrings.get("License"),
                    appInfo.get("ProjectPage")),
            true);
    System.exit(0);
}

From source file:eu.stratosphere.yarn.Client.java

private void printUsage() {
    System.out.println("Usage:");
    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(200);//from  ww w  . j  a v a 2s  .c o  m
    formatter.setLeftPadding(5);
    formatter.setSyntaxPrefix("   Required");
    Options req = new Options();
    req.addOption(CONTAINER);
    formatter.printHelp(" ", req);

    formatter.setSyntaxPrefix("   Optional");
    Options opt = new Options();
    opt.addOption(VERBOSE);
    //   opt.addOption(GEN_CONF);
    //   opt.addOption(STRATOSPHERE_CONF);
    //   opt.addOption(STRATOSPHERE_JAR);
    opt.addOption(JM_MEMORY);
    opt.addOption(TM_MEMORY);
    opt.addOption(TM_CORES);
    opt.addOption(QUERY);
    opt.addOption(QUEUE);
    formatter.printHelp(" ", opt);
}

From source file:eu.stratosphere.pact.client.CliFrontend.java

/**
 * Prints the help for the client./* ww w. j av a2s.c  om*/
 * 
 * @param options A map with options for actions. 
 */
private void printHelp() {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setLeftPadding(5);

    System.out.println("./pact-client [ACTION] [GENERAL_OPTIONS] [ACTION_ARGUMENTS]");

    formatter.setSyntaxPrefix("  general options:");
    formatter.printHelp(" ", this.options.get(GENERAL_OPTS));

    System.out.println("\nAction \"run\" compiles and submits a PACT program.");
    formatter.setSyntaxPrefix("  \"run\" action arguments:");
    formatter.printHelp(" ", this.options.get(ACTION_RUN));

    System.out.println("\nAction \"info\" displays information about a PACT program.");
    formatter.setSyntaxPrefix("  \"info\" action arguments:");
    formatter.printHelp(" ", this.options.get(ACTION_INFO));

    System.out.println("\nAction \"list\" lists submitted PACT programs.");
    formatter.setSyntaxPrefix("  \"list\" action arguments:");
    formatter.printHelp(" ", this.options.get(ACTION_LIST));

    System.out.println("\nAction \"cancel\" cancels a submitted PACT program.");
    formatter.setSyntaxPrefix("  \"cancel\" action arguments:");
    formatter.printHelp(" ", this.options.get(ACTION_CANCEL));

}

From source file:com.comcast.oscar.cli.CommandRun.java

/**
 * Checks all the commands from the user. Order is IMPORTANT. Do not rearrange without full understanding.
 * @param args//from ww  w . jav  a2 s  .  c  om
 */
public void run(String[] args) {
    BasicParser parser = new BasicParser();
    Options options = new Options();
    BuildOptions.run(options);

    try {
        CommandLine line = parser.parse(options, args);
        HelpFormatter hf = new HelpFormatter();
        hf.setWidth(180);
        hf.setLeftPadding(5);
        hf.setDescPadding(5);

        if (line.hasOption("h")) {
            hf.printHelp(Constants.OSCAR_CLI_USAGE, options);
        }

        if (line.hasOption("version")) {
            System.out.println(Constants.APACHE_20_LICENCE_DISCLAIMER);
            System.out.println(Constants.OSCAR_VERSION);
        }

        if (line.hasOption("s")) {
            comSpecification.setValues(line.getOptionValues("s"));

            if (comSpecification.getConfigurationFileType() == -1) {
                System.err.println(Specification.ERROR);
                System.exit(1);
            }

            if (comSpecification.getTlvDisassemble() == null) {
                System.err.println(Specification.ERROR);
                System.exit(1);
            }
        }

        if (line.hasOption("i")) {
            comInput = new Input(line.getOptionValues("i"));

            if (!comInput.hasInput()) {
                System.err.println(Input.ERROR);
                System.exit(1);
            }
        }

        if (line.hasOption("o")) {
            comOutput = new Output(line.getOptionValues("o"));
        }

        if (line.hasOption("k")) {
            comKey.setKey(line.getOptionValues("k"));
        }

        if (line.hasOption("mbb")) {
            comMergeBulk = new MergeBulk(line.getOptionValues("mbb"));

            if (comMergeBulk.hasInputDir()) {
                comMergeBulk.mergeFiles(comSpecification.getConfigurationFileType(), comKey.getKey());
            } else {
                System.err.println(MergeBulk.ERROR);
                System.exit(1);
            }
        }

        if (line.hasOption("f")) {
            comFirmware = new Firmware(line.getOptionValues("f"));
        }

        if (line.hasOption("T")) {
            comTFTPServer = new TFTPServer(line.getOptionValues("T"));

            if (!comTFTPServer.hasAddress()) {
                System.err.println(TFTPServer.ERROR);
                System.exit(1);
            }
        }

        if (line.hasOption("m")) {
            comMaxCPE = new MaxCPE(line.getOptionValues("m"));
        }

        if (line.hasOption("df")) {
            comDownstreamFrequency = new DownstreamFrequency(line.getOptionValues("df"));
        }

        if (line.hasOption("cvc")) {
            comCVC = new CVC(line.getOptionValues("cvc"));

            if (!comCVC.hasCVC()) {
                System.err.println(CVC.ERROR);
                System.exit(1);
            }
        }

        if (line.hasOption("t")) {
            comTLV = new TLV(line.getOptionValues("t"));
        }

        if (line.hasOption("dm")) {
            comDigitmapInsert = new DigitmapInsert(line.getOptionValues("dm"));

            if (!comDigitmapInsert.hasDigitmap()) {
                System.err.println(DigitmapInsert.ERROR);
                System.exit(1);
            }
        }

        if (line.hasOption("O")) {
            comOID = new OID(line.getOptionValues("O"));

            if (!comOID.hasOID()) {
                System.err.println(OID.ERROR);
                System.exit(1);
            }
        }

        if (line.hasOption("d")) {
            comDecompile = new Decompile(line.getOptionValues("d"));
            decompile();
        }

        if (line.hasOption("c")) {
            compile();
        }

        if (line.hasOption("b")) {
            String[] optionValues = line.getOptionValues("b");

            if (optionValues.length >= 3) {
                bulkBuild(optionValues[0]);
                bulkBuildCommand(new File(optionValues[1]), new File(optionValues[2]));
            } else if (optionValues.length >= 2) {
                bulkBuild(optionValues[0]);
                bulkBuildCommand(new File(optionValues[1]));
            } else {
                System.err.println(Constants.ERR_MIS_PAR);
                hf.printHelp(Constants.OSCAR_CLI_USAGE, options);
            }
        }

        if (line.hasOption("ftd")) {
            comFullTLVDisplay.printFullTLVDisplay(comSpecification.getConfigurationFileType());
        }

        if (line.hasOption("x")) {
            comHexDisplay = new HexDisplay(line.getOptionValues("x"));

            if (comInput.hasInput()) {
                if (comInput.isBinary()) {
                    comHexDisplay.printHexDisplayFromBinary(comInput.getInput());
                } else {
                    comHexDisplay.printHexDisplayFromText(comInput.getInput(),
                            comSpecification.getConfigurationFileType());
                }
            } else {
                System.err.println(Input.ERROR);
                System.exit(1);
            }
        }

        if (line.hasOption("j")) {
            if (comInput.hasInput()) {
                if (comInput.isBinary()) {
                    comJSONDisplay.printJSONDisplayFromBinary(comInput.getInput(),
                            comSpecification.getTlvDisassemble(), comSpecification.getConfigurationFileType());
                } else {
                    comJSONDisplay.printJSONDisplayFromText(comInput.getInput(),
                            comSpecification.getTlvDisassemble());
                }
            } else {
                System.err.println(Input.ERROR);
                System.exit(1);
            }
        }

        if (line.hasOption("ddm")) {
            if (comInput.hasInput()) {
                if (comInput.isBinary()) {
                    comDigitmapDisplay.printDigitmapDisplayFromBinary(comInput.getInput());
                } else {
                    comDigitmapDisplay.printDigitmapDisplayFromText(comInput.getInput());
                }
            }
        }

        if (line.hasOption("j2t")) {
            comJSONtoTLV = new JSONtoTLV(line.getOptionValues("j2t"));

            if (comJSONtoTLV.fileExists()) {
                comJSONtoTLV.printTLV();
            } else {
                System.err.println(JSONtoTLV.ERROR);
            }
        }

        if (line.hasOption("t2j")) {
            comTLVtoJSON = new TLVtoJSON(line.getOptionValues("t2j"));
            comTLVtoJSON.printJSON(comSpecification.getTlvDisassemble());
        }

        if (line.hasOption("td")) {
            comTLVDescription = new TLVDescription(line.getOptionValues("td"));
            comTLVDescription.printTLVDescription(comSpecification.getConfigurationFileType());
        }

        if (line.hasOption("tr")) {
            comTranslate = new Translate(line.getOptionValues("tr"));
            comTranslate.translate();
        }
    } catch (ParseException exp) {
        System.err.println("Parsing failed. Reason: " + exp.getMessage());
    }
}

From source file:eu.stratosphere.client.CliFrontend.java

private void printHelpForInfo() {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setLeftPadding(5);
    formatter.setWidth(80);//from  w ww. j a v  a 2  s  . c  om

    System.out.println("\nAction \"info\" displays information about a program.");
    formatter.setSyntaxPrefix("  \"info\" action arguments:");
    formatter.printHelp(" ", getInfoOptionsWithoutDeprecatedOptions(new Options()));
}

From source file:eu.stratosphere.client.CliFrontend.java

private void printHelpForList() {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setLeftPadding(5);
    formatter.setWidth(80);/*w ww. j  a  va  2s  .  co m*/

    System.out.println("\nAction \"list\" lists running and finished programs.");
    formatter.setSyntaxPrefix("  \"list\" action arguments:");
    formatter.printHelp(" ", getListOptions(new Options()));
}

From source file:eu.stratosphere.client.CliFrontend.java

private void printHelpForCancel() {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setLeftPadding(5);
    formatter.setWidth(80);/*from ww w .j  a v a2s.  c  om*/

    System.out.println("\nAction \"cancel\" cancels a running program.");
    formatter.setSyntaxPrefix("  \"cancel\" action arguments:");
    formatter.printHelp(" ", getCancelOptions(new Options()));
}

From source file:eu.stratosphere.client.CliFrontend.java

private void printHelpForRun() {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setLeftPadding(5);
    formatter.setWidth(80);//from w  w w. ja va 2 s  . c  o m

    System.out.println("\nAction \"run\" compiles and runs a program.");
    System.out.println("\n  Syntax: run [OPTIONS] <jar-file> <arguments>");
    formatter.setSyntaxPrefix("  \"run\" action arguments:");
    formatter.printHelp(" ", getRunOptionsWithoutDeprecatedOptions(new Options()));
}

From source file:eu.stratosphere.client.CliFrontend.java

/**
 * Prints the help for the client.//from w w w . j  a  v  a 2s .  c om
 * 
 * @param options A map with options for actions. 
 */
private void printHelp() {
    System.out.println("./stratosphere <ACTION> [GENERAL_OPTIONS] [ARGUMENTS]");

    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(80);
    formatter.setLeftPadding(5);
    formatter.setSyntaxPrefix("  general options:");
    formatter.printHelp(" ", GENRAL_OPTIONS);

    printHelpForRun();
    printHelpForInfo();
    printHelpForList();
    printHelpForCancel();
}

From source file:org.apache.flink.client.cli.CliFrontendParser.java

public static void printHelpForRun() {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setLeftPadding(5);
    formatter.setWidth(80);/*from w  w  w  .j  av a 2  s  . co  m*/

    System.out.println("\nAction \"run\" compiles and runs a program.");
    System.out.println("\n  Syntax: run [OPTIONS] <jar-file> <arguments>");
    formatter.setSyntaxPrefix("  \"run\" action options:");
    formatter.printHelp(" ", getRunOptionsWithoutDeprecatedOptions(new Options()));

    printCustomCliOptions(formatter, true);

    System.out.println();
}