Ejemplo n.º 1
0
  public static void main(String[] args) {

    String formatstr = "ws [--in][--out][--dd][--sw][-h]";
    Options opt = new Options();
    // opt.addOption(OptionBuilder.withArgName("in").hasArg().withDescription("search for buildfile
    // towards the root of the filesystem and use it").create("O"));
    opt.addOption(
        OptionBuilder.withLongOpt("in")
            .withDescription("file path of those files need to be processed")
            .withValueSeparator('=')
            .hasArg()
            .create());
    opt.addOption(
        OptionBuilder.withLongOpt("out")
            .withDescription("file path to store result")
            .withValueSeparator('=')
            .hasArg()
            .create());
    opt.addOption(
        OptionBuilder.withLongOpt("dd")
            .withDescription("file path of dictionary")
            .withValueSeparator('=')
            .hasArg()
            .create());
    opt.addOption(
        OptionBuilder.withLongOpt("sw")
            .withDescription("file path of stop words")
            .withValueSeparator('=')
            .hasArg()
            .create());
    opt.addOption("h", "help", false, "print help for the command.");

    if (args.length == 0) {
      HelpFormatter hf = new HelpFormatter();
      hf.printHelp(formatstr, "", opt, "");
      return;
    } else {
      parse_args(args, formatstr, opt);
    }
  }
Ejemplo n.º 2
0
  @SuppressWarnings({"AccessStaticViaInstance"})
  public static Options createCompilationOptions() {
    //
    // Parse the command line

    Options options = new Options();

    options.addOption(
        OptionBuilder.hasArg()
            .withArgName("path")
            .withDescription("Specify where to find the class files - must be first argument")
            .create("classpath"));
    options.addOption(
        OptionBuilder.withLongOpt("classpath")
            .hasArg()
            .withArgName("path")
            .withDescription("Aliases for '-classpath'")
            .create("cp"));
    options.addOption(
        OptionBuilder.withLongOpt("sourcepath")
            .hasArg()
            .withArgName("path")
            .withDescription("Specify where to find the source files")
            .create());
    options.addOption(
        OptionBuilder.withLongOpt("temp")
            .hasArg()
            .withArgName("temp")
            .withDescription("Specify temporary directory")
            .create());
    options.addOption(
        OptionBuilder.withLongOpt("encoding")
            .hasArg()
            .withArgName("encoding")
            .withDescription("Specify the encoding of the user class files")
            .create());
    options.addOption(
        OptionBuilder.hasArg()
            .withDescription("Specify where to place generated class files")
            .create('d'));
    //            options.addOption(OptionBuilder.withLongOpt("strict").withDescription("Turn on
    // strict type safety.").create('s'));
    options.addOption(
        OptionBuilder.withLongOpt("help")
            .withDescription("Print a synopsis of standard options")
            .create('h'));
    options.addOption(
        OptionBuilder.withLongOpt("version").withDescription("Print the version").create('v'));
    options.addOption(
        OptionBuilder.withLongOpt("exception")
            .withDescription("Print stack trace on error")
            .create('e'));
    options.addOption(
        OptionBuilder.withLongOpt("jointCompilation")
            .withDescription("Attach javac compiler to compile .java files")
            .create('j'));
    options.addOption(
        OptionBuilder.withLongOpt("basescript")
            .hasArg()
            .withArgName("class")
            .withDescription("Base class name for scripts (must derive from Script)")
            .create('b'));

    options.addOption(
        OptionBuilder.withArgName("property=value")
            .withValueSeparator()
            .hasArgs(2)
            .withDescription("name-value pairs to pass to javac")
            .create("J"));
    options.addOption(
        OptionBuilder.withArgName("flag")
            .hasArg()
            .withDescription("passed to javac for joint compilation")
            .create("F"));

    options.addOption(
        OptionBuilder.withLongOpt("indy")
            .withDescription("enables compilation using invokedynamic")
            .create());
    options.addOption(
        OptionBuilder.withLongOpt("configscript")
            .hasArg()
            .withDescription("A script for tweaking the configuration options")
            .create());
    return options;
  }