Package org.apache.commons.cli2.util

Examples of org.apache.commons.cli2.util.HelpFormatter


    }

  }

  private static void printHelp(Group group) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setGroup(group);
    formatter.print();
  }
View Full Code Here


    Parser parser = new Parser();
    parser.setHelpOption(help);
    parser.setHelpTrigger("--help");
    parser.setGroup(normalArgs);
    parser.setHelpFormatter(new HelpFormatter(" ", "", " ", 130));
    CommandLine cmdLine = parser.parseAndHelp(args);

    if (cmdLine == null) {
      return false;
    }
View Full Code Here

    Parser parser = new Parser();
    parser.setHelpOption(help);
    parser.setHelpTrigger("--help");
    parser.setGroup(normalArgs);
    parser.setHelpFormatter(new HelpFormatter(" ", "", " ", 130));
    CommandLine cmdLine = parser.parseAndHelp(args);

    if (cmdLine == null) {
      return false;
    }
View Full Code Here

    }

  }

  private static void printHelp(Group group) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setGroup(group);
    formatter.print();
  }
View Full Code Here

    }
   
  }
 
  private static void printHelp(Group group) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setGroup(group);
    formatter.print();
  }
View Full Code Here

                        .withOption(options)
                        .withOption(commands)
                        .withMinimum(0)
                        .create();

        HelpFormatter hf = new HelpFormatter();
        StringBuffer sep = new StringBuffer(hf.getPageWidth());
        while (sep.length() < hf.getPageWidth()) {
            sep.append("-");
        }
        hf.setHeader("File Vault version 1.0");
        hf.setDivider(sep.toString());
        hf.setShellCommand("vlt [options] <command> [arg1 [arg2 [arg3] ..]]");
        hf.setGroup(main);
        //hf.setHeader("bla bla version vla");
        //displayHelp();
        hf.getFullUsageSettings().removeAll(DisplaySetting.ALL);

        //hf.getDisplaySettings().add(DisplaySetting.DISPLAY_PARENT_ARGUMENT);
        //hf.getDisplaySettings().add(DisplaySetting.DISPLAY_PARENT_CHILDREN);

        //hf.getFullUsageSettings().remove(DisplaySetting.DISPLAY_OPTIONAL);
        hf.getFullUsageSettings().remove(DisplaySetting.DISPLAY_GROUP_ARGUMENT);
        hf.getFullUsageSettings().remove(DisplaySetting.DISPLAY_GROUP_EXPANDED);

        hf.getDisplaySettings().remove(DisplaySetting.DISPLAY_GROUP_ARGUMENT);
        hf.getDisplaySettings().remove(DisplaySetting.DISPLAY_PARENT_CHILDREN);
        hf.getDisplaySettings().add(DisplaySetting.DISPLAY_OPTIONAL);

        //hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_PROPERTY_OPTION);
        //hf.getLineUsageSettings().remove(DisplaySetting.DISPLAY_GROUP_ARGUMENT);
        //hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_GROUP_NAME);
        //hf.getLineUsageSettings().remove(DisplaySetting.DISPLAY_PARENT_CHILDREN);
        //hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_GROUP_ARGUMENT);
        //hf.getLineUsageSettings().remove(DisplaySetting.DISPLAY_GROUP_EXPANDED);
        //hf.getLineUsageSettings().remove(DisplaySetting.DISPLAY_PARENT_CHILDREN);
        //hf.getLineUsageSettings().remove(DisplaySetting.DISPLAY_PARENT_CHILDREN);

        hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_PROPERTY_OPTION);
        hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_PARENT_ARGUMENT);
        hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_ARGUMENT_BRACKETED);

        Parser parser = new Parser();
        parser.setHelpFormatter(hf);
        parser.setGroup(main);
        System.out.println(main);

        CommandLine cl = parser.parseAndHelp(args);
        if (cl != null) {
            if (exit.execute(null, cl)) {
                System.out.println("exit executed");
            } else if (help.execute(null, cl)) {
                System.out.println("help executed.");
            } else {
                hf.print();
            }
        }
    }
View Full Code Here

public final class CommandLineUtil {
 
  private CommandLineUtil() { }
 
  public static void printHelp(Group group) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setGroup(group);
    formatter.print();
  }
View Full Code Here

   * @param group job-specific command-line options.
   */
  public static void printHelpWithGenericOptions(Group group) throws IOException {
    new GenericOptionsParser(new Configuration(), new org.apache.commons.cli.Options(), new String[0]);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charsets.UTF_8), true);
    HelpFormatter formatter = new HelpFormatter();
    formatter.setGroup(group);
    formatter.setPrintWriter(pw);
    formatter.setFooter("Specify HDFS directories while running on hadoop; else specify local file system directories");
    formatter.print();
  }
View Full Code Here

  }

  public static void printHelpWithGenericOptions(Group group, OptionException oe) throws IOException {
    new GenericOptionsParser(new Configuration(), new org.apache.commons.cli.Options(), new String[0]);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charsets.UTF_8), true);
    HelpFormatter formatter = new HelpFormatter();
    formatter.setGroup(group);
    formatter.setPrintWriter(pw);
    formatter.setException(oe);
    formatter.print();
  }
View Full Code Here

    Parser parser = new Parser();
    parser.setHelpOption(help);
    parser.setHelpTrigger("--help");
    parser.setGroup(normalArgs);
    parser.setHelpFormatter(new HelpFormatter(" ", "", " ", 150));

    CommandLine cmdLine = parser.parseAndHelp(args);
    if (cmdLine == null) {
      return false;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.cli2.util.HelpFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.