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:com.jgaap.backend.CLI.java

/**
 * Parses the arguments passed to jgaap from the command line. Will either
 * display the help or run jgaap on an experiment.
 * /*from   w w  w.j ava2 s  .  c o m*/
 * @param args
 *            command line arguments
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    CommandLineParser parser = new GnuParser();
    CommandLine cmd = parser.parse(options, args);
    if (cmd.hasOption('h')) {
        String command = cmd.getOptionValue('h');
        if (command == null) {
            HelpFormatter helpFormatter = new HelpFormatter();
            helpFormatter.setLeftPadding(5);
            helpFormatter.setWidth(100);
            helpFormatter.printHelp(
                    "jgaap -c [canon canon ...] -es [event] -ec [culler culler ...] -a [analysis] <-d [distance]> -l [file] <-s [file]>",
                    "Welcome to JGAAP the Java Graphical Authorship Attribution Program.\nMore information can be found at http://jgaap.com",
                    options, "Copyright 2013 Evaluating Variation in Language Lab, Duquesne University");
        } else {
            List<Displayable> list = new ArrayList<Displayable>();
            if (command.equalsIgnoreCase("c")) {
                list.addAll(Canonicizers.getCanonicizers());
            } else if (command.equalsIgnoreCase("es")) {
                list.addAll(EventDrivers.getEventDrivers());
            } else if (command.equalsIgnoreCase("ec")) {
                list.addAll(EventCullers.getEventCullers());
            } else if (command.equalsIgnoreCase("a")) {
                list.addAll(AnalysisDrivers.getAnalysisDrivers());
            } else if (command.equalsIgnoreCase("d")) {
                list.addAll(DistanceFunctions.getDistanceFunctions());
            } else if (command.equalsIgnoreCase("lang")) {
                list.addAll(Languages.getLanguages());
            }
            for (Displayable display : list) {
                if (display.showInGUI())
                    System.out.println(display.displayName() + " - " + display.tooltipText());
            }
            if (list.isEmpty()) {
                System.out.println("Option " + command + " was not found.");
                System.out.println("Please use c, es, d, a, or lang");
            }
        }
    } else if (cmd.hasOption('v')) {
        System.out.println("Java Graphical Authorship Attribution Program version 5.2.0");
    } else if (cmd.hasOption("ee")) {
        String eeFile = cmd.getOptionValue("ee");
        String lang = cmd.getOptionValue("lang");
        ExperimentEngine.runExperiment(eeFile, lang);
        System.exit(0);
    } else {
        JGAAP.commandline = true;
        API api = API.getPrivateInstance();
        String documentsFilePath = cmd.getOptionValue('l');
        if (documentsFilePath == null) {
            throw new Exception("No Documents CSV specified");
        }
        List<Document> documents;
        if (documentsFilePath.startsWith(JGAAPConstants.JGAAP_RESOURCE_PACKAGE)) {
            documents = Utils.getDocumentsFromCSV(
                    CSVIO.readCSV(com.jgaap.JGAAP.class.getResourceAsStream(documentsFilePath)));
        } else {
            documents = Utils.getDocumentsFromCSV(CSVIO.readCSV(documentsFilePath));
        }
        for (Document document : documents) {
            api.addDocument(document);
        }
        String language = cmd.getOptionValue("lang", "english");
        api.setLanguage(language);
        String[] canonicizers = cmd.getOptionValues('c');
        if (canonicizers != null) {
            for (String canonicizer : canonicizers) {
                api.addCanonicizer(canonicizer);
            }
        }
        String[] events = cmd.getOptionValues("es");
        if (events == null) {
            throw new Exception("No EventDriver specified");
        }
        for (String event : events) {
            api.addEventDriver(event);
        }
        String[] eventCullers = cmd.getOptionValues("ec");
        if (eventCullers != null) {
            for (String eventCuller : eventCullers) {
                api.addEventCuller(eventCuller);
            }
        }
        String analysis = cmd.getOptionValue('a');
        if (analysis == null) {
            throw new Exception("No AnalysisDriver specified");
        }
        AnalysisDriver analysisDriver = api.addAnalysisDriver(analysis);
        String distanceFunction = cmd.getOptionValue('d');
        if (distanceFunction != null) {
            api.addDistanceFunction(distanceFunction, analysisDriver);
        }
        api.execute();
        List<Document> unknowns = api.getUnknownDocuments();
        OutputStreamWriter outputStreamWriter;
        String saveFile = cmd.getOptionValue('s');
        if (saveFile == null) {
            outputStreamWriter = new OutputStreamWriter(System.out);
        } else {
            outputStreamWriter = new OutputStreamWriter(new FileOutputStream(saveFile));
        }
        Writer writer = new BufferedWriter(outputStreamWriter);
        for (Document unknown : unknowns) {
            writer.append(unknown.getFormattedResult(analysisDriver));
        }
        writer.append('\n');
    }
}

From source file:com.aleggeup.util.App.java

private static void printHelp(final Options options) {
    final HelpFormatter formatter = new HelpFormatter();

    formatter.setLeftPadding(4);
    formatter.printHelp("phrame-man", AppOptions.HELP_HEADER, options, AppOptions.HELP_FOOTER, true);
}

From source file:net.aepik.alasca.plugin.schemaquery.SchemaQueryTool.java

/**
 * Print usage./*  w ww.  ja  v a2  s .  c o  m*/
 */
private static void displayHelp() {
    HelpFormatter h = new HelpFormatter();
    h.setLeftPadding(4);
    h.printHelp("alascaquery", options, true);
}

From source file:com.dattack.dbping.cli.PingCli.java

private static void showUsage(final Options options) {
    final HelpFormatter formatter = new HelpFormatter();
    final int descPadding = 5;
    final int leftPadding = 4;
    formatter.setDescPadding(descPadding);
    formatter.setLeftPadding(leftPadding);
    final String header = "\n";
    final String footer = "\nPlease report issues at https://github.com/dattack/dbtools/issues";
    formatter.printHelp("dbping ", header, options, footer, true);
}

From source file:net.aepik.alasca.plugin.schemaconverter.SCTool.java

/**
 * Print usage./*from w  ww . jav  a2 s .  c o m*/
 */
private static void displayHelp() {
    HelpFormatter h = new HelpFormatter();
    h.setLeftPadding(4);
    h.printHelp("alascaconv", options, true);
}

From source file:com.dattack.dbcopy.cli.DbCopyCli.java

private static void showUsage(final Options options) {
    final HelpFormatter formatter = new HelpFormatter();
    final int descPadding = 5;
    final int leftPadding = 4;
    formatter.setDescPadding(descPadding);
    formatter.setLeftPadding(leftPadding);
    final String header = "\n";
    final String footer = "\nPlease report issues at https://github.com/dattack/dbcopy/issues";
    formatter.printHelp("dbcopy ", header, options, footer, true);
}

From source file:com.dattack.dbtools.drules.DrulesClient.java

private static void showUsage(final Options options) {
    final HelpFormatter formatter = new HelpFormatter();
    final int descPadding = 5;
    final int leftPadding = 4;
    formatter.setDescPadding(descPadding);
    formatter.setLeftPadding(leftPadding);
    final String header = "\n";
    final String footer = "\nPlease report issues at https://github.com/dattack/dbtools/issues";
    formatter.printHelp("drules ", header, options, footer, true);
}

From source file:at.favre.tools.dconvert.ui.CLIInterpreter.java

private static void printHelp(Options options) {
    HelpFormatter help = new HelpFormatter();
    help.setWidth(110);//from w  w w  . j  av  a  2  s  .  co  m
    help.setLeftPadding(4);
    help.printHelp("converter", "version: " + CLIInterpreter.class.getPackage().getImplementationVersion(),
            options, "", true);
}

From source file:com.eucalyptus.upgrade.TestHarness.java

@SuppressWarnings({ "static-access" })
private static void printHelp(Options opts) {
    try {//from w ww .ja v a2  s .com
        PrintWriter out = new PrintWriter(System.out);
        HelpFormatter help = new HelpFormatter();
        help.setArgName("TESTS");
        help.printHelp(out, LINE_BYTES, "java -jar test.jar", "Options controlling the test harness.", opts, 2,
                4, "", true);
        Multimap<Class, Method> testMethods = getTestMethods();
        help = new HelpFormatter();
        help.setLongOptPrefix("");
        help.setOptPrefix("");
        help.setSyntaxPrefix("");
        help.setLeftPadding(0);
        Options testOptions = new Options();
        for (Class c : testMethods.keySet()) {
            testOptions.addOption(
                    OptionBuilder.withDescription(getDescription(c)).withLongOpt(c.getSimpleName()).create());
            for (Method m : testMethods.get(c)) {
                testOptions.addOption(OptionBuilder.withDescription(getDescription(m))
                        .withLongOpt(c.getSimpleName() + "." + m.getName()).create());
            }
        }
        help.printHelp(out, LINE_BYTES, " ", "Tests:", testOptions, 0, 2, "", false);
        out.flush();
    } catch (Exception e) {
        System.out.println(e);
        System.exit(1);
    }
}

From source file:com.github.codingtogenomic.CodingToGenomic.java

private static void showHelp(Options o, String msg, Integer exitVal) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setOptionComparator(new OptionComparator());
    formatter.setLeftPadding(8);
    formatter.setWidth(80);//from w  w  w  .jav a 2 s. c om
    if (msg != null) {
        System.out.println("\nERROR: " + msg);
    }
    formatter.printHelp("CodingToGenomic " + "[-g <gene>] [-c <coordinate>] [options]\n", o, false);
    System.out.println("");
    System.exit(exitVal);
}