/** Set up the command line options. */
    protected void setupOptions(Options opts) {
      // boolean options
      opts.addOption("a", "verify", false, "verify generated signatures>");

      OptionBuilder.hasArg();
      OptionBuilder.withArgName("dir");
      OptionBuilder.withLongOpt("key-directory");
      OptionBuilder.withDescription("directory to find key files (default '.').");
      opts.addOption(OptionBuilder.create('D'));

      OptionBuilder.hasArg();
      OptionBuilder.withArgName("time/offset");
      OptionBuilder.withLongOpt("start-time");
      OptionBuilder.withDescription("signature starting time (default is now - 1 hour)");
      opts.addOption(OptionBuilder.create('s'));

      OptionBuilder.hasArg();
      OptionBuilder.withArgName("time/offset");
      OptionBuilder.withLongOpt("expire-time");
      OptionBuilder.withDescription("signature expiration time (default is start-time + 30 days).");
      opts.addOption(OptionBuilder.create('e'));

      OptionBuilder.hasArg();
      OptionBuilder.withArgName("outfile");
      OptionBuilder.withDescription("file the signed rrset is written to.");
      opts.addOption(OptionBuilder.create('f'));
    }
Beispiel #2
0
  public void test13425() {
    Options options = new Options();
    Option oldpass =
        OptionBuilder.withLongOpt("old-password")
            .withDescription("Use this option to specify the old password")
            .hasArg()
            .create('o');
    Option newpass =
        OptionBuilder.withLongOpt("new-password")
            .withDescription("Use this option to specify the new password")
            .hasArg()
            .create('n');

    String[] args = {"-o", "-n", "newpassword"};

    options.addOption(oldpass);
    options.addOption(newpass);

    Parser parser = new PosixParser();

    try {
      CommandLine line = parser.parse(options, args);
    }
    // catch the exception and leave the method
    catch (Exception exp) {
      assertTrue(exp != null);
      return;
    }
    fail("MissingArgumentException not caught.");
  }
Beispiel #3
0
  public void buildOptions() {
    Options options = new Options();

    // Option help = new Option( "H","help",false,"print this message" );

    // Option disable = new Option ("DL","disable",false,"Disable a user");

    options.addOption(
        OptionBuilder.withLongOpt("username")
            .withDescription("The username to perform the action on")
            .isRequired()
            .withValueSeparator('=')
            .hasArg()
            .create("U"));

    options.addOption(
        OptionBuilder.withLongOpt("action")
            .withDescription(
                "The action to perform on the specified user, action can be: [disable|reset_pass]")
            .isRequired()
            .withValueSeparator('=')
            .hasArg()
            .create("A"));

    // options.addOption( help );
    // options.addOption(disable);

    setOptions(options);
  }
 @SuppressWarnings({"AccessStaticViaInstance"})
 private static Options createOptions() {
   Options options = new Options();
   options.addOption("?", false, "Show this message");
   options.addOption(
       OptionBuilder.withLongOpt("root")
           .hasArg()
           .isRequired()
           .withDescription("Source root, eg. /svnwork/prr/trunk/working")
           .create());
   options.addOption(
       OptionBuilder.withLongOpt("moves")
           .hasArg()
           .isRequired()
           .withDescription("File listing class moves, organized by Maven artifact")
           .create());
   options.addOption(
       OptionBuilder.withLongOpt("package")
           .hasArg()
           .withDescription("Restrict analysis to classes under the specified package")
           .create());
   options.addOption(
       OptionBuilder.withLongOpt("group")
           .hasArg()
           .withDescription("Restrict analysis to Maven modules with the specified group prefix")
           .create());
   options.addOption(
       OptionBuilder.withLongOpt("refs")
           .hasArg()
           .withDescription("Extra set of references to take into consideration")
           .create());
   return options;
 }
  /*
   * most this code is boiler plate. All you need to modify is createOptions
   * and main to get a server working!
   */
  public static Options createOptions() {
    Option port =
        OptionBuilder.withLongOpt("port")
            .withArgName("PORT")
            .hasArg()
            .withDescription("port to open server on")
            .create("p");
    Option threads =
        OptionBuilder.withLongOpt("threads")
            .withArgName("THREADS")
            .hasArg()
            .withDescription("number of threads to run")
            .create("t");
    Option config =
        OptionBuilder.withLongOpt("config")
            .withArgName("CONFIG")
            .hasArg()
            .withDescription("configuration file")
            .create("c");

    Option kbest = new Option("k", "kbest", false, "run a kbest server");
    Option help = new Option("h", "help", false, "print this message");
    Options options = new Options();
    options.addOption(port);
    options.addOption(threads);
    options.addOption(config);
    options.addOption(kbest);
    options.addOption(help);
    return options;
  }
 private static Option createPortfolioNameOption() {
   OptionBuilder.withLongOpt("portfolio");
   OptionBuilder.withDescription("The name of the portfolio to create/update");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(PORTFOLIO_NAME_OPT);
 }
 private static Option createOptionDepthOption() {
   OptionBuilder.withLongOpt("depth");
   OptionBuilder.withDescription("Number of options on either side of the strike price");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(OPTION_DEPTH_OPT);
 }
 private static Option createNumContractsOption() {
   OptionBuilder.withLongOpt("contracts");
   OptionBuilder.withDescription("Number of contracts for each option");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(NUM_CONTRACTS_OPT);
 }
 private static Option createNumMembersOption() {
   OptionBuilder.withLongOpt("members");
   OptionBuilder.withDescription("Number underlyers from index to include");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(NUM_INDEX_MEMBERS_OPT);
 }
Beispiel #10
0
 @SuppressWarnings("static-access")
 private static void addDestinationOption(Options opts) {
   opts.addOption(
       OptionBuilder.withLongOpt("dest")
           .hasArg()
           .withArgName("aet")
           .withDescription(rb.getString("dest"))
           .create());
 }
  /**
   * Build command-line options and descriptions
   *
   * @return command line options
   */
  public static Options buildOptions() {
    Options options = new Options();

    // Build in/output file arguments, which are required, but there is no
    // addOption method that can specify this
    OptionBuilder.isRequired();
    OptionBuilder.hasArgs();
    OptionBuilder.withLongOpt("outputFilename");
    options.addOption(OptionBuilder.create("o"));

    OptionBuilder.isRequired();
    OptionBuilder.hasArgs();
    OptionBuilder.withLongOpt("inputFilename");
    options.addOption(OptionBuilder.create("i"));

    options.addOption("p", "processor", true, "");
    options.addOption("v", "verbose", false, "");
    options.addOption("h", "help", false, "");

    return options;
  }
 @SuppressWarnings("static-access")
 private static Option optionsUsingManifest() {
   return OptionBuilder.withLongOpt("manifest")
       .withDescription(
           "\nUse a custom module manager manifest file. "
               + "The manifest must specify the default module to load, "
               + "the location of the modules folder and any configuration files "
               + "that are needed for the drivers you would like to use.")
       .hasArg()
       .withArgName("PATH")
       .create();
 }
Beispiel #13
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);
    }
  }
Beispiel #14
0
  @SuppressWarnings("static-access")
  private Options getOptions() {
    if (options == null) {
      options = new Options();

      options.addOption(
          OptionBuilder.withLongOpt("start").withDescription("Start a cache").create('s'));

      options.addOption(
          OptionBuilder.withLongOpt("kill").hasArg().withDescription("Kill a cache").create('s'));

      options.addOption(
          OptionBuilder.withLongOpt("port")
              .hasArg()
              .withDescription("Port to initialize Nimbus with.")
              .create('p'));
      options.addOption(
          OptionBuilder.withLongOpt("name")
              .hasArg()
              .withDescription("Name of this Cache.")
              .create('n'));
      options.addOption(
          OptionBuilder.withLongOpt("type").hasArg().withDescription("Cache type.").create('t'));

      options.addOption(
          OptionBuilder.withLongOpt("help")
              .withDescription("Displays this help message.")
              .create());
    }
    return options;
  }
  @Override
  @SuppressWarnings("static-access")
  public Options buildCliOptions(Options options) {
    options.addOption(
        OptionBuilder.withLongOpt("repository")
            .hasArg()
            .withDescription("The repository to be converted.")
            .create(REPO));

    options.addOption(
        OptionBuilder.withLongOpt("output")
            .hasArg()
            .withDescription("Where the converted repositories locate.")
            .create(OUTPUT));

    options.addOption(
        OptionBuilder.withLongOpt("move")
            .withDescription("Move the repository (old repository will be deleted ).")
            .create(MOVE));

    this.options = options;

    return options;
  }
Beispiel #16
0
  public void test11457() {
    Options options = new Options();
    options.addOption(OptionBuilder.withLongOpt("verbose").create());
    String[] args = new String[] {"--verbose"};

    CommandLineParser parser = new PosixParser();

    try {
      CommandLine cmd = parser.parse(options, args);
      assertTrue(cmd.hasOption("verbose"));
    } catch (ParseException exp) {
      exp.printStackTrace();
      fail("Unexpected Exception: " + exp.getMessage());
    }
  }
  /** Initializes {@link #options} with all information the options parser needs. */
  public OptionsConfiguration() {
    super();
    // w/ argument
    OptionBuilder.withDescription(OptionDescriptor.PATH_PREFIX.getDescription());
    OptionBuilder.withArgName("PATH");
    OptionBuilder.hasArg();
    OptionBuilder.withLongOpt(OptionDescriptor.PATH_PREFIX.getLongOption());
    options.addOption(OptionBuilder.create(OptionDescriptor.PATH_PREFIX.getShortOption()));
    OptionBuilder.withDescription(OptionDescriptor.INPUT_ENCODING.getDescription());
    OptionBuilder.withArgName("ENCODING");
    OptionBuilder.hasArg();
    OptionBuilder.withLongOpt(OptionDescriptor.INPUT_ENCODING.getLongOption());
    options.addOption(OptionBuilder.create(OptionDescriptor.INPUT_ENCODING.getShortOption()));
    OptionBuilder.withDescription(OptionDescriptor.OUTPUT_ENCODING.getDescription());
    OptionBuilder.withArgName("ENCODING");
    OptionBuilder.hasArg();
    OptionBuilder.withLongOpt(OptionDescriptor.OUTPUT_ENCODING.getLongOption());
    options.addOption(OptionBuilder.create(OptionDescriptor.OUTPUT_ENCODING.getShortOption()));

    // w/o argument
    options.addOption(
        OptionDescriptor.DEBUG.getShortOption(),
        OptionDescriptor.DEBUG.getLongOption(),
        false,
        OptionDescriptor.DEBUG.getDescription());
    options.addOption(
        OptionDescriptor.HELP.getShortOption(),
        OptionDescriptor.HELP.getLongOption(),
        false,
        OptionDescriptor.HELP.getDescription());
    options.addOption(
        OptionDescriptor.VERSION.getShortOption(),
        OptionDescriptor.VERSION.getLongOption(),
        false,
        OptionDescriptor.VERSION.getDescription());
  }
Beispiel #18
0
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    // create the command line parser
    CommandLineParser parser = new PosixParser();

    // create the Options
    Options options = new Options();
    options.addOption("a", "all", false, "do not hide entries starting with .");
    options.addOption("A", "almost-all", false, "do not list implied . and ..");
    options.addOption("b", "escape", false, "print octal escapes for nongraphic " + "characters");
    options.addOption(
        OptionBuilder.withLongOpt("block-size")
            .withDescription("use SIZE-byte blocks")
            .hasArg()
            .withArgName("SIZE")
            .create());
    options.addOption(
        "B", "ignore-backups", false, "do not list implied entried " + "ending with ~");
    options.addOption(
        "c",
        false,
        "with -lt: sort by, and show, ctime (time of last "
            + "modification of file status information) with "
            + "-l:show ctime and sort by name otherwise: sort "
            + "by ctime");
    options.addOption("C", false, "list entries by columns");

    String[] args2 = new String[] {"--all=12"};

    try {
      // parse the command line arguments
      CommandLine line = parser.parse(options, args2);

      // validate that block-size has been set
      if (line.hasOption("block-size")) {
        // print the value of block-size
        System.out.println(line.getOptionValue("all"));
      }
    } catch (ParseException exp) {
      System.out.println("Unexpected exception:" + exp.getMessage());
    }
  }
Beispiel #19
0
  @Override
  protected Options getOptions() {
    Options opts = super.getOptions();

    opts.addOption(
        OptionBuilder.withLongOpt(CMD_OPT_USERID)
            .withDescription("The id of the user to view or edit")
            .hasArg()
            .create("i"));

    opts.addOption(
        OptionBuilder.withLongOpt(CMD_OPT_USERNAME)
            .withDescription("The username of the user to view or edit")
            .hasArg()
            .create("u"));

    opts.addOption(
        OptionBuilder.withLongOpt(CMD_OPT_PASSWORD)
            .withDescription("The password value to set")
            .hasArg()
            .create());

    opts.addOption(
        OptionBuilder.withLongOpt(CMD_OPT_PRIVILEGES)
            .withDescription(
                "Comma separated list of privileges to set, one or more of: "
                    + privilegesAsString(Privilege.ALL))
            .hasArg()
            .create("p"));

    opts.addOption(
        OptionBuilder.withLongOpt(CMD_OPT_AUTHORIZATIONS)
            .withDescription("Comma separated list of authorizations to set, or none")
            .hasOptionalArg()
            .create("a"));

    opts.addOption(
        OptionBuilder.withLongOpt(CMD_OPT_AS_TABLE)
            .withDescription("List users in a table")
            .create("t"));

    return opts;
  }
Beispiel #20
0
 @SuppressWarnings("static-access")
 private static CommandLine parseCommandLine(String[] args) throws ParseException {
   Options options = new Options();
   options.addOption(
       OptionBuilder.withLongOpt("no-check-impl-cuid")
           .withDescription(NO_CHECK_IMPL_CUID)
           .create());
   options.addOption(
       OptionBuilder.withLongOpt("check-impl-cuid")
           .hasArg()
           .withArgName("uid")
           .withDescription(CHECK_IMPL_CUID)
           .create());
   options.addOption(
       OptionBuilder.withLongOpt("no-new-impl-cuid").withDescription(NO_NEW_IMPL_CUID).create());
   options.addOption(
       OptionBuilder.withLongOpt("new-impl-cuid")
           .hasArg()
           .withArgName("uid")
           .withDescription(NEW_IMPL_CUID)
           .create());
   options.addOption(
       OptionBuilder.withLongOpt("help").withDescription("display this help and exit").create());
   options.addOption(
       OptionBuilder.withLongOpt("version")
           .withDescription("output version information and exit")
           .create());
   CommandLineParser parser = new PosixParser();
   CommandLine cl = parser.parse(options, args);
   if (cl.hasOption("help")) {
     HelpFormatter formatter = new HelpFormatter();
     formatter.printHelp(USAGE, DESCRIPTION, options, EXAMPLE);
     return null;
   }
   if (cl.hasOption("version")) {
     System.out.println("fixjpegls " + FixJpegLS.class.getPackage().getImplementationVersion());
     return null;
   }
   return cl;
 }
Beispiel #21
0
  public void test27635() {
    Option help = new Option("h", "help", false, "print this message");
    Option version = new Option("v", "version", false, "print version information");
    Option newRun = new Option("n", "new", false, "Create NLT cache entries only for new items");
    Option trackerRun =
        new Option("t", "tracker", false, "Create NLT cache entries only for tracker items");

    Option timeLimit =
        OptionBuilder.withLongOpt("limit")
            .hasArg()
            .withValueSeparator()
            .withDescription("Set time limit for execution, in mintues")
            .create("l");

    Option age =
        OptionBuilder.withLongOpt("age")
            .hasArg()
            .withValueSeparator()
            .withDescription("Age (in days) of cache item before being recomputed")
            .create("a");

    Option server =
        OptionBuilder.withLongOpt("server")
            .hasArg()
            .withValueSeparator()
            .withDescription("The NLT server address")
            .create("s");

    Option numResults =
        OptionBuilder.withLongOpt("results")
            .hasArg()
            .withValueSeparator()
            .withDescription("Number of results per item")
            .create("r");

    Option configFile =
        OptionBuilder.withLongOpt("config")
            .hasArg()
            .withValueSeparator()
            .withDescription("Use the specified configuration file")
            .create();

    Options mOptions = new Options();
    mOptions.addOption(help);
    mOptions.addOption(version);
    mOptions.addOption(newRun);
    mOptions.addOption(trackerRun);
    mOptions.addOption(timeLimit);
    mOptions.addOption(age);
    mOptions.addOption(server);
    mOptions.addOption(numResults);
    mOptions.addOption(configFile);

    HelpFormatter formatter = new HelpFormatter();
    final String EOL = System.getProperty("line.separator");
    StringWriter out = new StringWriter();
    formatter.printHelp(
        new PrintWriter(out), 80, "commandline", "header", mOptions, 2, 2, "footer", true);
    assertEquals(
        "usage: commandline [-a <arg>] [--config <arg>] [-h] [-l <arg>] [-n] [-r <arg>]"
            + EOL
            + "       [-s <arg>] [-t] [-v]"
            + EOL
            + "header"
            + EOL
            + "  -a,--age <arg>      Age (in days) of cache item before being recomputed"
            + EOL
            + "     --config <arg>   Use the specified configuration file"
            + EOL
            + "  -h,--help           print this message"
            + EOL
            + "  -l,--limit <arg>    Set time limit for execution, in mintues"
            + EOL
            + "  -n,--new            Create NLT cache entries only for new items"
            + EOL
            + "  -r,--results <arg>  Number of results per item"
            + EOL
            + "  -s,--server <arg>   The NLT server address"
            + EOL
            + "  -t,--tracker        Create NLT cache entries only for tracker items"
            + EOL
            + "  -v,--version        print version information"
            + EOL
            + "footer"
            + EOL,
        out.toString());
  }
Beispiel #22
0
  /**
   * Build the options parser. Has to be synchronized because of the way Options are constructed.
   *
   * @return an options parser.
   */
  @SuppressWarnings("static-access")
  private static synchronized Options buildOptions() {
    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("define")
            .withDescription("define a system property")
            .hasArg(true)
            .withArgName("name=value")
            .create('D'));
    options.addOption(
        OptionBuilder.withLongOpt("disableopt")
            .withDescription(
                "disables one or all optimization elements. "
                    + "optlist can be a comma separated list with the elements: "
                    + "all (disables all optimizations), "
                    + "int (disable any int based optimizations)")
            .hasArg(true)
            .withArgName("optlist")
            .create());
    options.addOption(
        OptionBuilder.hasArg(false)
            .withDescription("usage information")
            .withLongOpt("help")
            .create('h'));
    options.addOption(
        OptionBuilder.hasArg(false)
            .withDescription("debug mode will print out full stack traces")
            .withLongOpt("debug")
            .create('d'));
    options.addOption(
        OptionBuilder.hasArg(false)
            .withDescription("display the Groovy and JVM versions")
            .withLongOpt("version")
            .create('v'));
    options.addOption(
        OptionBuilder.withArgName("charset")
            .hasArg()
            .withDescription("specify the encoding of the files")
            .withLongOpt("encoding")
            .create('c'));
    options.addOption(
        OptionBuilder.withArgName("script")
            .hasArg()
            .withDescription("specify a command line script")
            .create('e'));
    options.addOption(
        OptionBuilder.withArgName("extension")
            .hasOptionalArg()
            .withDescription(
                "modify files in place; create backup if extension is given (e.g. \'.bak\')")
            .create('i'));
    options.addOption(
        OptionBuilder.hasArg(false)
            .withDescription("process files line by line using implicit 'line' variable")
            .create('n'));
    options.addOption(
        OptionBuilder.hasArg(false)
            .withDescription("process files line by line and print result (see also -n)")
            .create('p'));
    options.addOption(
        OptionBuilder.withArgName("port")
            .hasOptionalArg()
            .withDescription("listen on a port and process inbound lines (default: 1960)")
            .create('l'));
    options.addOption(
        OptionBuilder.withArgName("splitPattern")
            .hasOptionalArg()
            .withDescription(
                "split lines using splitPattern (default '\\s') using implicit 'split' variable")
            .withLongOpt("autosplit")
            .create('a'));
    options.addOption(
        OptionBuilder.withLongOpt("indy")
            .withDescription("enables compilation using invokedynamic")
            .create());

    return options;
  }
  /** load options * */
  void loadOptions(Options options) {

    @SuppressWarnings("static-access")
    Option subjectName =
        OptionBuilder.withLongOpt("subject_name")
            .withDescription("name of the subject (string)")
            .hasArg()
            .withArgName("VAL")
            .create();

    @SuppressWarnings("static-access")
    Option validate =
        OptionBuilder.withLongOpt("validate")
            .withDescription(
                "flag to indicate whether or not to check validity of configuration (boolean)")
            .hasArg()
            .withArgName("VAL")
            .create();

    @SuppressWarnings("static-access")
    Option splitMerge =
        OptionBuilder.withLongOpt("split_merge")
            .withDescription(
                "flag to indicate whether or not should split and merge configurations (boolean)")
            .hasArg()
            .withArgName("VAL")
            .create();

    @SuppressWarnings("static-access")
    Option num_samples =
        OptionBuilder.withLongOpt("samp_rate")
            .withDescription("sampling rate(double)")
            .hasArg()
            .withArgName("VAL")
            .create();

    @SuppressWarnings("static-access")
    Option rand_seed1 =
        OptionBuilder.withLongOpt("rand_seed1")
            .withDescription("random seed 1: to randomly select inst from a cluster")
            .hasArg()
            .withArgName("VAL")
            .create();

    @SuppressWarnings("static-access")
    Option incl_ratio =
        OptionBuilder.withLongOpt("incl_ratio")
            .withDescription("include pass/fail ratio for clustering(boolean)")
            .hasArg()
            .withArgName("VAL")
            .create();

    @SuppressWarnings("static-access")
    Option totNum =
        OptionBuilder.withLongOpt("totNum")
            .withDescription("subject.arff size")
            .hasArg()
            .withArgName("VAL")
            .create();

    @SuppressWarnings("static-access")
    Option method1 =
        OptionBuilder.withLongOpt("method1")
            .withDescription(
                "sample 1 instance from each cluster, where #clusters = #samples (Boolean)")
            .hasArg()
            .withArgName("VAL")
            .create();

    @SuppressWarnings("static-access")
    Option dataDir =
        OptionBuilder.withLongOpt("data_dir")
            .withDescription("Path to directory data")
            .hasArg()
            .withArgName("VAL")
            .create();

    @SuppressWarnings("static-access")
    Option stopFirst =
        OptionBuilder.withLongOpt("stpFrstValid")
            .withDescription("Stop when first valid configuration is found")
            .hasArg()
            .withArgName("VAL")
            .create();

    subjectName.setRequired(true);
    splitMerge.setRequired(true);
    // num_samples.setRequired(true);
    // rand_seed1.setRequired(true);
    // incl_ratio.setRequired(true);
    // method1.setRequired(true);

    // adding options to list
    options.addOption(num_samples);
    options.addOption(rand_seed1);
    options.addOption(incl_ratio);
    options.addOption(method1);
    options.addOption(totNum);
    options.addOption(stopFirst);
    // adding options to list
    options.addOption(subjectName);
    options.addOption(validate);
    options.addOption(splitMerge);
    options.addOption(dataDir);
  }
Beispiel #24
0
  // create options displayed in the krun help
  @SuppressWarnings("static-access")
  public void initializeKRunOptions() {

    addOptionS(
        OptionBuilder.withLongOpt("help").withDescription("Print this help message.").create("h"));
    addOptionS(
        OptionBuilder.withLongOpt("version")
            .withDescription("Print version information.")
            .create());
    addOptionS(OptionBuilder.withLongOpt("verbose").withDescription("Verbose output.").create("v"));

    // Common K options
    addOptionS(
        OptionBuilder.withLongOpt("directory")
            .hasArg()
            .withArgName("dir")
            .withDescription(
                "Path to the directory in which the kompiled K definition resides. The default is the current directory.")
            .create("d"));
    addOptionS(
        OptionBuilder.withLongOpt("main-module")
            .hasArg()
            .withArgName("name")
            .withDescription(
                "Specify main module in which a program starts to execute. The default is the module specified in the given compiled K definition.")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("syntax-module")
            .hasArg()
            .withArgName("name")
            .withDescription(
                "Specify main module for syntax. The default is the module specified in the given compiled K definition.")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("io")
            .hasArg()
            .withArgName("[on|off]")
            .withDescription("Use real IO when running the definition. (Default: enabled).")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("color")
            .hasArg()
            .withArgName("[on|off|extended]")
            .withDescription("Use colors in output. (Default: on).")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("terminal-color")
            .hasArg()
            .withArgName("color-name")
            .withDescription(
                "Background color of the terminal. Cells won't be colored in this color. (Default: black).")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("parens")
            .hasArg()
            .withArgName("[greedy|smart]")
            .withDescription(
                "Select the parentheses-insertion algorithm. The default value is 'greedy'. Note that 'smart' can take much longer time to execute.")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("parser")
            .hasArg()
            .withArgName("command")
            .withDescription("Command used to parse programs. (Default: kast).")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("config-var-parser")
            .hasArg()
            .withArgName("file")
            .withDescription(
                "Command used to parse configuration variables. (Default: kast -e).  See --parser above. Applies to subsequent -c options until another parser is specified with this option.")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("config-var")
            .hasArgs(2)
            .withValueSeparator('=')
            .withArgName("name=value")
            .withDescription("Specify values for variables in the configuration.")
            .create("c"));
    addOptionS(
        OptionBuilder.withLongOpt("output")
            .hasArg()
            .withArgName("mode")
            .withDescription(
                "How to display Maude results. <mode> is either [pretty|raw|binary|none]. (Default: pretty).")
            .create("o"));

    // Advanced K options
    addOptionS(
        OptionBuilder.withLongOpt("search")
            .withDescription(
                "In conjunction with it you can specify 3 options that are optional: pattern (the pattern used for search), bound (the number of desired solutions) and depth (the maximum depth of the search).")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("search-final")
            .withDescription(
                "Same as --search but only return final states, even if --depth is provided.")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("search-all")
            .withDescription(
                "Same as --search but return all matching states, even if --depth is not provided.")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("search-one-step")
            .withDescription("Same as --search but search only one transition step.")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("search-one-or-more-steps")
            .withDescription("Same as --search-all but exclude initial state, even if it matches.")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("pattern")
            .hasArg()
            .withArgName("string")
            .withDescription(
                "Specify a term and/or side condition that the result of execution or search must match in order to succeed. Return the resulting matches as a list of substitutions. In conjunction with it you can specify other 2 options that are optional: bound (the number of desired solutions) and depth (the maximum depth of the search).")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("bound")
            .hasArg()
            .withArgName("num")
            .withDescription("The number of desired solutions for search.")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("depth")
            .hasArg()
            .withArgName("num")
            .withDescription(
                "The maximum number of computational steps to execute or search the definition for.")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("graph")
            .withDescription("Displays the search graph generated by the last search.")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("backend")
            .hasArg()
            .withArgName("backend")
            .withDescription(
                "Specify the krun backend to execute with. <backend> is either [maude|java]. (Default: maude).")
            .create());
    addOptionS(
        OptionBuilder.withLongOpt("help-experimental")
            .withDescription("Print help on non-standard options.")
            .create("X"));
    addOptionS(
        OptionBuilder.withLongOpt("simulation")
            .hasArg()
            .withArgName("string")
            .withDescription("Simulation property of two programs in two semantics.")
            .create());

    // Experimental options
    addOptionE(
        OptionBuilder.withLongOpt("fast-kast")
            .withDescription("Using the (experimental) faster C SDF parser.")
            .create());
    addOptionE(
        OptionBuilder.withLongOpt("statistics")
            .hasArg()
            .withArgName("[on|off]")
            .withDescription("Print Maude's rewrite statistics. (Default: ...).")
            .create());
    addOptionE(
        OptionBuilder.withLongOpt("term")
            .hasArg()
            .withArgName("string")
            .withDescription(
                "Input argument will be parsed with the specified parser and used as the sole input to krun.")
            .create());
    addOptionE(
        OptionBuilder.withLongOpt("maude-cmd")
            .hasArg()
            .withArgName("string")
            .withDescription("Maude command used to execute the definition.")
            .create());

    addOptionE(
        OptionBuilder.withLongOpt("log-io")
            .hasArg()
            .withArgName("[on|off]")
            .withDescription("Make the IO server create logs. (Default: disabled).")
            .create());
    addOptionE(
        OptionBuilder.withLongOpt("debug")
            .withDescription("Run an execution in debug mode.")
            .create());
    addOptionE(
        OptionBuilder.withLongOpt("debug-gui")
            .withDescription("Run an execution in debug mode with graphical interface.")
            .create());
    addOptionE(
        OptionBuilder.withLongOpt("debug-info")
            .withDescription("Provide debugging information.")
            .create());
    addOptionE(OptionBuilder.withLongOpt("trace").withDescription("Turn on maude trace.").create());
    addOptionE(
        OptionBuilder.withLongOpt("profile").withDescription("Turn on maude profiler.").create());
    addOptionE(
        OptionBuilder.withLongOpt("ltlmc")
            .hasArg()
            .withArgName("file/string")
            .withDescription(
                "Specify the formula for model checking through a file or at commandline.")
            .create());
    addOptionE(
        OptionBuilder.withLongOpt("prove")
            .hasArg()
            .withArgName("file")
            .withDescription("Prove a set of reachability rules.")
            .create());
    addOptionE(
        OptionBuilder.withLongOpt("smt")
            .hasArg()
            .withArgName("solver")
            .withDescription(
                "SMT solver to use for checking constraints. <solver> is either [z3|gappa|none]. (Default: z3).")
            .create());
    addOptionE(
        OptionBuilder.withLongOpt("generate-tests")
            .withDescription("Test programs will be generated along with normal search.")
            .create());

    addOptionE(
        OptionBuilder.withLongOpt("output-file")
            .hasArg()
            .withArgName("file")
            .withDescription("Store output in the file instead of displaying it.")
            .create());
    addOptionE(
        OptionBuilder.withLongOpt("load-cfg")
            .hasArg()
            .withArgName("file")
            .withDescription(
                "Load a configuration saved with the \"binary\" output mode into the $PGM configuration variable instead of a program.")
            .create());
  }
Beispiel #25
0
 /** * 添加工具执行时的选项 */
 private static void option() {
   // 添加 -f 选项
   OptionBuilder.withLongOpt("from");
   OptionBuilder.withDescription("new Apk file path.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("loc");
   Option fromOption = OptionBuilder.create("f");
   patchOptions.addOption(fromOption);
   allOptions.addOption(fromOption);
   // 添加 -t 选项
   OptionBuilder.withLongOpt("to");
   OptionBuilder.withDescription("old Apk file path.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("loc");
   Option toOption = OptionBuilder.create("t");
   patchOptions.addOption(toOption);
   allOptions.addOption(toOption);
   // 添加 -k 选项
   OptionBuilder.withLongOpt("keystore");
   OptionBuilder.withDescription("keystore path.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("loc");
   Option keystoreOption = OptionBuilder.create("k");
   patchOptions.addOption(keystoreOption);
   mergeOptions.addOption(keystoreOption);
   allOptions.addOption(keystoreOption);
   // 添加 -p 选项
   OptionBuilder.withLongOpt("kpassword");
   OptionBuilder.withDescription("keystore password.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("***");
   Option kPasswordOption = OptionBuilder.create("p");
   patchOptions.addOption(kPasswordOption);
   mergeOptions.addOption(kPasswordOption);
   allOptions.addOption(kPasswordOption);
   // 添加 -a 选项
   OptionBuilder.withLongOpt("alias");
   OptionBuilder.withDescription("alias.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("alias");
   Option aliasOption = OptionBuilder.create("a");
   patchOptions.addOption(aliasOption);
   mergeOptions.addOption(aliasOption);
   allOptions.addOption(aliasOption);
   // 添加 -e 选项
   OptionBuilder.withLongOpt("epassword");
   OptionBuilder.withDescription("entry password.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("***");
   Option ePasswordOption = OptionBuilder.create("e");
   patchOptions.addOption(ePasswordOption);
   mergeOptions.addOption(ePasswordOption);
   allOptions.addOption(ePasswordOption);
   // 添加 -o 选项
   OptionBuilder.withLongOpt("out");
   OptionBuilder.withDescription("output dir.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("dir");
   Option outOption = OptionBuilder.create("o");
   patchOptions.addOption(outOption);
   mergeOptions.addOption(outOption);
   allOptions.addOption(outOption);
   // 添加 -n 选项
   OptionBuilder.withLongOpt("name");
   OptionBuilder.withDescription("patch name.");
   OptionBuilder.hasArg(true);
   OptionBuilder.withArgName("name");
   Option nameOption = OptionBuilder.create("n");
   patchOptions.addOption(nameOption);
   mergeOptions.addOption(nameOption);
   allOptions.addOption(nameOption);
   // 添加 -m 选项
   OptionBuilder.withLongOpt("merge");
   OptionBuilder.withDescription("path of .apatch files.");
   OptionBuilder.hasArg(false);
   OptionBuilder.withArgName("loc...");
   Option mergeOption = OptionBuilder.create("m");
   mergeOptions.addOption(mergeOption);
   allOptions.addOption(mergeOption);
 }
Beispiel #26
0
  protected Util(String[] args) {
    CommandLineParser cmdLineParse = new PosixParser();

    Options options = new Options();
    options.addOption("h", "help", false, "show this help message and exit");
    options.addOption(
        OptionBuilder.withLongOpt("host")
            .withDescription("host to connect to (default 0.0.0.0)")
            .hasArg(true)
            .withArgName("HOST")
            .create('H'));
    options.addOption(
        OptionBuilder.withLongOpt("username")
            .withDescription("username to use for authentication")
            .hasArg(true)
            .withArgName("USERNAME")
            .create('u'));
    options.addOption(
        OptionBuilder.withLongOpt("password")
            .withDescription("password to use for authentication")
            .hasArg(true)
            .withArgName("PASSWORD")
            .create('w'));
    options.addOption(
        OptionBuilder.withLongOpt("port")
            .withDescription("port to connect to (default 5672)")
            .hasArg(true)
            .withArgName("PORT")
            .create('p'));
    options.addOption(
        OptionBuilder.withLongOpt("frame-size")
            .withDescription("specify the maximum frame size")
            .hasArg(true)
            .withArgName("FRAME_SIZE")
            .create('f'));
    options.addOption(
        OptionBuilder.withLongOpt("container-name")
            .withDescription("Container name")
            .hasArg(true)
            .withArgName("CONTAINER_NAME")
            .create('C'));

    options.addOption(OptionBuilder.withLongOpt("ssl").withDescription("Use SSL").create('S'));

    options.addOption(
        OptionBuilder.withLongOpt("remote-hostname")
            .withDescription("hostname to supply in the open frame")
            .hasArg(true)
            .withArgName("HOST")
            .create('O'));

    if (hasBlockOption())
      options.addOption(
          OptionBuilder.withLongOpt("block")
              .withDescription("block until messages arrive")
              .create('b'));

    if (hasCountOption())
      options.addOption(
          OptionBuilder.withLongOpt("count")
              .withDescription("number of messages to send (default 1)")
              .hasArg(true)
              .withArgName("COUNT")
              .create('c'));
    if (hasModeOption())
      options.addOption(
          OptionBuilder.withLongOpt("acknowledge-mode")
              .withDescription(
                  "acknowledgement mode: AMO|ALO|EO (At Least Once, At Most Once, Exactly Once")
              .hasArg(true)
              .withArgName("MODE")
              .create('k'));

    if (hasSubjectOption())
      options.addOption(
          OptionBuilder.withLongOpt("subject")
              .withDescription("subject message property")
              .hasArg(true)
              .withArgName("SUBJECT")
              .create('s'));

    if (hasSingleLinkPerConnectionMode())
      options.addOption(
          OptionBuilder.withLongOpt("single-link-per-connection")
              .withDescription(
                  "acknowledgement mode: AMO|ALO|EO (At Least Once, At Most Once, Exactly Once")
              .hasArg(false)
              .create('Z'));

    if (hasFilterOption())
      options.addOption(
          OptionBuilder.withLongOpt("filter")
              .withDescription("filter, e.g. exact-subject=hello; matching-subject=%.a.#")
              .hasArg(true)
              .withArgName("<TYPE>=<VALUE>")
              .create('F'));

    if (hasTxnOption()) {
      options.addOption("x", "txn", false, "use transactions");
      options.addOption(
          OptionBuilder.withLongOpt("batch-size")
              .withDescription("transaction batch size (default: 1)")
              .hasArg(true)
              .withArgName("BATCH-SIZE")
              .create('B'));
      options.addOption(
          OptionBuilder.withLongOpt("rollback-ratio")
              .withDescription("rollback ratio - must be between 0 and 1 (default: 0)")
              .hasArg(true)
              .withArgName("RATIO")
              .create('R'));
    }

    if (hasLinkDurableOption()) {
      options.addOption("d", "durable-link", false, "use a durable link");
    }

    if (hasStdInOption())
      options.addOption("i", "stdin", false, "read messages from stdin (one message per line)");

    options.addOption(
        OptionBuilder.withLongOpt("trace")
            .withDescription("trace logging specified categories: RAW, FRM")
            .hasArg(true)
            .withArgName("TRACE")
            .create('t'));
    if (hasSizeOption())
      options.addOption(
          OptionBuilder.withLongOpt("message-size")
              .withDescription("size to pad outgoing messages to")
              .hasArg(true)
              .withArgName("SIZE")
              .create('z'));

    if (hasResponseQueueOption())
      options.addOption(
          OptionBuilder.withLongOpt("response-queue")
              .withDescription("response queue to reply to")
              .hasArg(true)
              .withArgName("RESPONSE_QUEUE")
              .create('r'));

    if (hasLinkNameOption()) {
      options.addOption(
          OptionBuilder.withLongOpt("link")
              .withDescription("link name")
              .hasArg(true)
              .withArgName("LINK")
              .create('l'));
    }

    if (hasWindowSizeOption()) {
      options.addOption(
          OptionBuilder.withLongOpt("window-size")
              .withDescription("credit window size")
              .hasArg(true)
              .withArgName("WINDOW-SIZE")
              .create('W'));
    }

    CommandLine cmdLine = null;
    try {
      cmdLine = cmdLineParse.parse(options, args);

    } catch (ParseException e) {
      printUsage(options);
      System.exit(-1);
    }

    if (cmdLine.hasOption('h') || cmdLine.getArgList().isEmpty()) {
      printUsage(options);
      System.exit(0);
    }
    _host = cmdLine.getOptionValue('H', "0.0.0.0");
    _remoteHost = cmdLine.getOptionValue('O', null);
    String portStr = cmdLine.getOptionValue('p', "5672");
    String countStr = cmdLine.getOptionValue('c', "1");

    _useSSL = cmdLine.hasOption('S');

    if (hasWindowSizeOption()) {
      String windowSizeStr = cmdLine.getOptionValue('W', "100");
      _windowSize = Integer.parseInt(windowSizeStr);
    }

    if (hasSubjectOption()) {
      _subject = cmdLine.getOptionValue('s');
    }

    if (cmdLine.hasOption('u')) {
      _username = cmdLine.getOptionValue('u');
    }

    if (cmdLine.hasOption('w')) {
      _password = cmdLine.getOptionValue('w');
    }

    if (cmdLine.hasOption('F')) {
      _filter = cmdLine.getOptionValue('F');
    }

    _port = Integer.parseInt(portStr);

    _containerName = cmdLine.getOptionValue('C');

    if (hasBlockOption()) _block = cmdLine.hasOption('b');

    if (hasLinkNameOption()) _linkName = cmdLine.getOptionValue('l');

    if (hasLinkDurableOption()) _durableLink = cmdLine.hasOption('d');

    if (hasCountOption()) _count = Integer.parseInt(countStr);

    if (hasStdInOption()) _useStdIn = cmdLine.hasOption('i');

    if (hasSingleLinkPerConnectionMode()) _useMultipleConnections = cmdLine.hasOption('Z');

    if (hasTxnOption()) {
      _useTran = cmdLine.hasOption('x');
      _batchSize = Integer.parseInt(cmdLine.getOptionValue('B', "1"));
      _rollbackRatio = Double.parseDouble(cmdLine.getOptionValue('R', "0"));
    }

    if (hasModeOption()) {
      _mode = AcknowledgeMode.ALO;

      if (cmdLine.hasOption('k')) {
        _mode = AcknowledgeMode.valueOf(cmdLine.getOptionValue('k'));
      }
    }

    if (hasResponseQueueOption()) {
      _responseQueue = cmdLine.getOptionValue('r');
    }

    _frameSize = Integer.parseInt(cmdLine.getOptionValue('f', "65536"));

    if (hasSizeOption()) {
      _messageSize = Integer.parseInt(cmdLine.getOptionValue('z', "-1"));
    }

    String categoriesList = cmdLine.getOptionValue('t');
    String[] categories = categoriesList == null ? new String[0] : categoriesList.split("[, ]");
    for (String cat : categories) {
      if (cat.equalsIgnoreCase("FRM")) {
        FRAME_LOGGER.setLevel(Level.FINE);
        Formatter formatter =
            new Formatter() {
              @Override
              public String format(final LogRecord record) {
                return "[" + record.getMillis() + " FRM]\t" + record.getMessage() + "\n";
              }
            };
        for (Handler handler : FRAME_LOGGER.getHandlers()) {
          FRAME_LOGGER.removeHandler(handler);
        }
        Handler handler = new ConsoleHandler();
        handler.setLevel(Level.FINE);
        handler.setFormatter(formatter);
        FRAME_LOGGER.addHandler(handler);
      } else if (cat.equalsIgnoreCase("RAW")) {
        RAW_LOGGER.setLevel(Level.FINE);
        Formatter formatter =
            new Formatter() {
              @Override
              public String format(final LogRecord record) {
                return "[" + record.getMillis() + " RAW]\t" + record.getMessage() + "\n";
              }
            };
        for (Handler handler : RAW_LOGGER.getHandlers()) {
          RAW_LOGGER.removeHandler(handler);
        }
        Handler handler = new ConsoleHandler();
        handler.setLevel(Level.FINE);
        handler.setFormatter(formatter);
        RAW_LOGGER.addHandler(handler);
      }
    }

    _args = cmdLine.getArgs();
  }
Beispiel #27
0
 public static void main(String[] arguments) {
   final CommandLineParser parser = new PosixParser();
   final Options opts = new Options();
   CommandLine cmd = null;
   Pipeline.addLogHelpAndInputOptions(opts);
   Pipeline.addTikaOptions(opts);
   Pipeline.addOutputOptions(opts);
   Pipeline.addJdbcResourceOptions(
       opts, DEFAULT_JDBC_DRIVER, DEFAULT_DB_PROVIDER, DEFAULT_DATABASE);
   // entity annotator options setup
   opts.addOption("Q", "query-file", true, "file with SQL SELECT queries");
   OptionBuilder.withLongOpt("query");
   OptionBuilder.withArgName("SELECT");
   OptionBuilder.hasArgs();
   OptionBuilder.withDescription("one or more SQL SELECT queries");
   opts.addOption(OptionBuilder.create('q'));
   opts.addOption(
       "m", "entity-map", true, "name of the entity map file [" + DEFAULT_MAPPING_FILE + "]");
   opts.addOption(
       "n", "namespace", true, "namespace of the entity annotations [" + DEFAULT_NAMESPACE + "]");
   try {
     cmd = parser.parse(opts, arguments);
   } catch (final ParseException e) {
     System.err.println(e.getLocalizedMessage());
     System.exit(1); // == exit ==
   }
   final Logger l =
       Pipeline.loggingSetup(cmd, opts, "txtfnnl entities [options] <directory|files...>\n");
   // output options
   XmiWriter.Builder writer =
       Pipeline.configureWriter(cmd, XmiWriter.configure(Pipeline.ensureOutputDirectory(cmd)));
   // DB resource
   ExternalResourceDescription jdbcResource = null;
   try {
     jdbcResource =
         Pipeline.getJdbcConnectionResource(
             cmd, l, DEFAULT_JDBC_DRIVER, DEFAULT_DB_PROVIDER, DEFAULT_DATABASE);
   } catch (final ClassNotFoundException e) {
     System.err.println("JDBC resoruce setup failed:");
     System.err.println(e.toString());
     System.exit(1); // == EXIT ==
   } catch (ResourceInitializationException e) {
     System.err.println("JDBC resoruce setup failed:");
     System.err.println(e.toString());
     System.exit(1); // == EXIT ==
   }
   /* BEGIN entity annotator */
   final String queryFileName = cmd.getOptionValue('Q');
   final String entityMapPath = cmd.getOptionValue('m', DEFAULT_MAPPING_FILE);
   final String namespace = cmd.getOptionValue('n', DEFAULT_NAMESPACE);
   String[] queries = cmd.getOptionValues('q');
   File entityMap; // m
   if (queryFileName != null) {
     final File queryFile = new File(queryFileName);
     if (!queryFile.isFile() || !queryFile.canRead()) {
       System.err.print("cannot read query file ");
       System.err.println(queryFile);
       System.exit(1); // == EXIT ==
     }
     String[] fileQueries = null;
     try {
       fileQueries =
           IOUtils.read(new FileInputStream(queryFile), Pipeline.inputEncoding(cmd)).split("\n");
     } catch (final Exception e) {
       System.err.print("cannot read query file ");
       System.err.print(queryFile);
       System.err.print(":");
       System.err.println(e.getLocalizedMessage());
       System.exit(1); // == EXIT ==
     }
     if (queries == null || queries.length == 0) {
       queries = fileQueries;
     } else {
       final String[] tmp = new String[queries.length + fileQueries.length];
       System.arraycopy(queries, 0, tmp, 0, queries.length);
       System.arraycopy(fileQueries, 0, tmp, queries.length, fileQueries.length);
       queries = tmp;
     }
   }
   entityMap = new File(entityMapPath);
   if (!entityMap.isFile() || !entityMap.canRead()) {
     System.err.print("cannot read entity map file ");
     System.err.println(entityMapPath);
     System.exit(1); // == EXIT ==
   }
   if (queries == null || queries.length == 0) {
     queries = DEFAULT_SQL_QUERIES;
   }
   /* END entity annotator */
   try {
     final Pipeline pipeline = new Pipeline(2); // tika and known entity annotator
     KnownEntityAnnotator.Builder builder =
         KnownEntityAnnotator.configure(namespace, queries, entityMap, jdbcResource);
     pipeline.setReader(cmd);
     pipeline.configureTika(cmd);
     pipeline.set(1, Pipeline.multiviewEngine(builder.create()));
     pipeline.setConsumer(Pipeline.textEngine(writer.create()));
     pipeline.run();
     pipeline.destroy();
   } catch (final UIMAException e) {
     l.severe(e.toString());
     System.err.println(e.getLocalizedMessage());
     System.exit(1); // == EXIT ==
   } catch (final IOException e) {
     l.severe(e.toString());
     System.err.println(e.getLocalizedMessage());
     System.exit(1); // == EXIT ==
   }
   System.exit(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;
  }
Beispiel #29
0
 // create options displayed in the krun debugger help
 @SuppressWarnings("static-access")
 public void initializeDebugOptions() {
   // stepper options
   addOptionS(
       OptionBuilder.withLongOpt("help")
           .withDescription("Display the available commands")
           .create());
   addOptionS(
       OptionBuilder.withLongOpt("step")
           .withDescription(
               "Execute one step or multiple steps at one time if you specify a positive integer argument")
           .create());
   addOptionS(
       OptionBuilder.withLongOpt("step-all")
           .withDescription(
               "Computes all successors in one or more transitions (if you specify a positive integer argument) of the current configuration")
           .create());
   addOptionS(
       OptionBuilder.withLongOpt("select")
           .hasArg()
           .withArgName("number")
           .withDescription(
               "Selects the current configuration after a search result using step-all command")
           .create());
   addOptionS(
       OptionBuilder.withLongOpt("show-search-graph")
           .withDescription("Displays the search graph generated by the last search")
           .create());
   addOptionS(
       OptionBuilder.withLongOpt("show-node")
           .hasArg()
           .withArgName("NODE")
           .withDescription(
               "Displays info about the specified node in the search graph."
                   + K.lineSeparator
                   + "The node is specified by its id indicated as argument of this option")
           .create());
   addOptionS(
       OptionBuilder.withLongOpt("show-edge")
           .hasArgs(2)
           .withArgName("NODE1 NODE2")
           .withDescription(
               "Displays info about the specifiede edge in the search graph."
                   + K.lineSeparator
                   + "The edge is specified by the ids of the endpoints indicated as argument of this option")
           .create());
   addOptionS(
       OptionBuilder.withLongOpt("resume")
           .withDescription("Resume the execution and exit from the debug mode")
           .create());
   addOptionS(
       OptionBuilder.withLongOpt("abort")
           .withDescription("Abort the execution and exit from the debug mode")
           .create());
   addOptionS(
       OptionBuilder.withLongOpt("save")
           .hasArg()
           .withArgName("STRING")
           .withDescription("Save the debug session to file")
           .create());
   addOptionS(
       OptionBuilder.withLongOpt("load")
           .hasArg()
           .withArgName("STRING")
           .withDescription("Load the debug session from file")
           .create());
   addOptionS(
       OptionBuilder.withLongOpt("read")
           .hasArg()
           .withArgName("STRING")
           .withDescription("Read a string from stdin")
           .create());
 }
Beispiel #30
0
  /**
   * Parsing command line.
   *
   * @param args
   */
  private void parseCommandLine(String[] args) {
    Options ops = new Options();

    // help
    OptionBuilder.withLongOpt("help");
    OptionBuilder.hasArg(false);
    OptionBuilder.withDescription(rb.getString("OPT_HELP_MSG"));
    ops.addOption(OptionBuilder.create("h"));

    // input file
    OptionBuilder.withLongOpt("input");
    OptionBuilder.hasArg(true);
    OptionBuilder.isRequired(true);
    OptionBuilder.withDescription(rb.getString("OPT_INPUT_MSG"));
    ops.addOption(OptionBuilder.create("i"));

    // input file
    OptionBuilder.withLongOpt("charset");
    OptionBuilder.hasArg(true);
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription(rb.getString("OPT_CHARSET_MSG"));
    ops.addOption(OptionBuilder.create("ch"));

    OptionBuilder.withDescription(rb.getString("OPT_CSV_MSG"));
    ops.addOption(OptionBuilder.create("csv"));

    OptionBuilder.withDescription(rb.getString("OPT_TABTXT_MSG"));
    ops.addOption(OptionBuilder.create("tab"));

    OptionBuilder.withDescription(rb.getString("OPT_DOUBLE_QUOTES"));
    ops.addOption(OptionBuilder.create("dq"));

    BasicParser parser = new BasicParser();

    try {
      CommandLine cl = parser.parse(ops, args);
      delimiter = ",";
      if (cl.hasOption("tab")) {
        delimiter = "\t";
      } else if (cl.hasOption("csv")) {
        delimiter = ",";
      }

      if (cl.hasOption("dq")) {
        // double quotes
        flgDoubleQuotes = true;
      } else {
        flgDoubleQuotes = false;
      }
      if (cl.hasOption("h")) {
        showHelp(ops);
      }

      charset = "UTF-8";
      if (cl.hasOption("ch")) {
        String val = cl.getOptionValue("ch");
        if (val != null && val.length() > 0) {
          charset = val;
        }
      }

      if (cl.hasOption("i")) {
        String val = cl.getOptionValue("i");
        if (val != null && val.length() > 0) {
          readExcel(val);
        }
      } else {
        showHelp(ops);
      }
    } catch (ParseException e) {
      showHelp(ops);
    }
  }