Exemple #1
1
  public void test13666() {
    Options options = new Options();
    Option dir = OptionBuilder.withDescription("dir").hasArg().create('d');
    options.addOption(dir);

    final PrintStream oldSystemOut = System.out;
    try {
      final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
      final PrintStream print = new PrintStream(bytes);

      // capture this platform's eol symbol
      print.println();
      final String eol = bytes.toString();
      bytes.reset();

      System.setOut(new PrintStream(bytes));
      try {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("dir", options);
      } catch (Exception exp) {
        fail("Unexpected Exception: " + exp.getMessage());
      }
      assertEquals("usage: dir" + eol + " -d <arg>   dir" + eol, bytes.toString());
    } finally {
      System.setOut(oldSystemOut);
    }
  }
  @SuppressWarnings("static-access")
  private static Options createOptions() {
    Options options = new Options();

    Option complex =
        OptionBuilder.withArgName("file")
            .hasArg()
            .isRequired()
            .withDescription("File containing filtered simplicial complex")
            .create("complex");
    Option points =
        OptionBuilder.withArgName("file")
            .hasArg()
            .isRequired()
            .withDescription("File containing list of data points")
            .create("points");
    Option output =
        OptionBuilder.withArgName("file")
            .hasArg()
            .isRequired(false)
            .withDescription(
                "Destination file (if omitted, filename will contain current timestamp)")
            .create("destination");

    options.addOption(complex);
    options.addOption(points);
    options.addOption(output);

    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;
  }
 @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;
 }
  @SuppressWarnings("static-access")
  public static void main(String[] args) throws Exception {
    Options options = new Options();
    options.addOption(
        OptionBuilder.withArgName("path")
            .hasArg()
            .withDescription("data file with tweet ids")
            .create(DATA_OPTION));
    options.addOption(
        OptionBuilder.withArgName("path")
            .hasArg()
            .withDescription("output file (*.gz)")
            .create(OUTPUT_OPTION));
    options.addOption(NOFOLLOW_OPTION, NOFOLLOW_OPTION, false, "don't follow 301 redirects");

    CommandLine cmdline = null;
    CommandLineParser parser = new GnuParser();
    try {
      cmdline = parser.parse(options, args);
    } catch (ParseException exp) {
      System.err.println("Error parsing command line: " + exp.getMessage());
      System.exit(-1);
    }

    if (!cmdline.hasOption(DATA_OPTION) || !cmdline.hasOption(OUTPUT_OPTION)) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp(ReadStatuses.class.getName(), options);
      System.exit(-1);
    }

    String data = cmdline.getOptionValue(DATA_OPTION);
    String output = cmdline.getOptionValue(OUTPUT_OPTION);
    boolean noFollow = cmdline.hasOption(NOFOLLOW_OPTION);
    new AsyncEmbeddedJsonStatusBlockCrawler(new File(data), output, noFollow).fetch();
  }
Exemple #6
0
  public void test11456() {
    // Posix
    Options options = new Options();
    options.addOption(OptionBuilder.hasOptionalArg().create('a'));
    options.addOption(OptionBuilder.hasArg().create('b'));
    String[] args = new String[] {"-a", "-bvalue"};

    CommandLineParser parser = new PosixParser();

    try {
      CommandLine cmd = parser.parse(options, args);
      assertEquals(cmd.getOptionValue('b'), "value");
    } catch (ParseException exp) {
      fail("Unexpected Exception: " + exp.getMessage());
    }

    // GNU
    options = new Options();
    options.addOption(OptionBuilder.hasOptionalArg().create('a'));
    options.addOption(OptionBuilder.hasArg().create('b'));
    args = new String[] {"-a", "-b", "value"};

    parser = new GnuParser();

    try {
      CommandLine cmd = parser.parse(options, args);
      assertEquals(cmd.getOptionValue('b'), "value");
    } catch (ParseException exp) {
      fail("Unexpected Exception: " + exp.getMessage());
    }
  }
Exemple #7
0
  /**
   * Create related options for SQL Server extra parameters.
   *
   * @return
   */
  @SuppressWarnings("static-access")
  private RelatedOptions getExtraOptions() {
    // Connection args (common)
    RelatedOptions extraOptions = new RelatedOptions("SQL Server extra options:");

    extraOptions.addOption(
        OptionBuilder.withArgName("string")
            .hasArg()
            .withDescription("Optional schema name")
            .withLongOpt(SCHEMA)
            .create());

    extraOptions.addOption(
        OptionBuilder.withArgName("string")
            .hasArg()
            .withDescription("Optional table hints to use")
            .withLongOpt(TABLE_HINTS)
            .create());

    extraOptions.addOption(
        OptionBuilder.withDescription("Allow identity inserts")
            .withLongOpt(IDENTITY_INSERT)
            .create());

    return extraOptions;
  }
  /** Creates the command line option. */
  @SuppressWarnings("static-access")
  private void createOptions() {
    options.addOption(
        OptionBuilder.withArgName("tools")
            .hasArg()
            .isRequired(true)
            .withDescription(
                "A tar.gz archive containing the required executables (see the readme for more information).")
            .create("t"));

    options.addOption(
        OptionBuilder.withArgName("input")
            .hasArg()
            .isRequired(true)
            .withDescription("Directory containing the input files.")
            .create("i"));

    options.addOption(
        OptionBuilder.withArgName("output")
            .hasArg()
            .isRequired(true)
            .withDescription(
                "Directory in which the results should be stored. Note that the directory itself should not exist, though the parent directory should.")
            .create("o"));

    options.addOption(
        OptionBuilder.withArgName("burrows_wheeler_align")
            .hasArg()
            .isRequired(true)
            .withDescription(
                "BWA reference fasta file. Other BWA index file should be present as well using the same prefix.")
            .create("bwa"));
  }
Exemple #9
0
 @SuppressWarnings("AccessStaticViaInstance")
 protected void initOptions(Options options) {
   options.addOption(new Option("h", "help", false, "print this message"));
   options.addOption(new Option("v", "version", false, "print the version information and exit"));
   options.addOption(new Option("c", "class", false, "generate a diagram class"));
   options.addOption(
       OptionBuilder.withArgName("path")
           .hasArg()
           .withDescription("dot executable path")
           .create("dot"));
   options.addOption(
       OptionBuilder.withArgName("path").hasArg().withDescription("input file").create("in"));
   options.addOption(
       OptionBuilder.withArgName("path").hasArg().withDescription("output file").create("out"));
   options.addOption(
       OptionBuilder.withArgName("fontname")
           .hasArg()
           .withDescription(
               "Font family name (be aware there are issues with name containing '.' or '-'...")
           .create("font"));
   options.addOption(
       OptionBuilder.withArgName("direction")
           .hasArg()
           .withDescription("Diagram direction: TD, LR...")
           .create("direction"));
 }
Exemple #10
0
  /** Get the command-line options */
  public static Options getOptions() {
    Option gsh =
        OptionBuilder.withArgName("gsh")
            .hasArg()
            .isRequired(false)
            .withDescription("grid service handle")
            .create("gsh");

    Option query =
        OptionBuilder.withArgName("query")
            .hasArg()
            .isRequired(false)
            .withDescription("query file")
            .create("query");

    Option printXml =
        OptionBuilder.withArgName("printXml")
            .isRequired(false)
            .withDescription("print xml results to stdout")
            .create("printXml");

    // add options
    Options options = new Options();

    options.addOption(gsh);
    options.addOption(query);
    options.addOption(printXml);

    return options;
  }
Exemple #11
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);
  }
Exemple #12
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.");
  }
Exemple #13
0
  @SuppressWarnings("static-access")
  public static void main(String[] args) throws Exception {
    Options options = new Options();
    options.addOption(
        OptionBuilder.withArgName("name")
            .hasArg()
            .withDescription("name of the archive")
            .create(NAME_OPTION));
    options.addOption(
        OptionBuilder.withArgName("path")
            .hasArg()
            .withDescription("WARC files location")
            .create(DIR_OPTION));
    options.addOption(
        OptionBuilder.withArgName("n")
            .hasArg()
            .withDescription("Start from the n-th WARC file")
            .create(START_OPTION));

    options.addOption("create", false, "create new table");
    options.addOption("append", false, "append to existing table");

    CommandLine cmdline = null;
    CommandLineParser parser = new GnuParser();
    try {
      cmdline = parser.parse(options, args);
    } catch (ParseException exp) {
      System.err.println("Error parsing command line: " + exp.getMessage());
      System.exit(-1);
    }

    if (!cmdline.hasOption(DIR_OPTION) || !cmdline.hasOption(NAME_OPTION)) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp(IngestFiles.class.getCanonicalName(), options);
      System.exit(-1);
    }

    if (!cmdline.hasOption(CREATE_OPTION) && !cmdline.hasOption(APPEND_OPTION)) {
      System.err.println(
          String.format("Must specify either -%s or -%s", CREATE_OPTION, APPEND_OPTION));
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp(IngestFiles.class.getCanonicalName(), options);
      System.exit(-1);
    }

    String path = cmdline.getOptionValue(DIR_OPTION);
    File inputFolder = new File(path);

    int i = 0;
    if (cmdline.hasOption(START_OPTION)) {
      i = Integer.parseInt(cmdline.getOptionValue(START_OPTION));
    }

    String name = cmdline.getOptionValue(NAME_OPTION);
    boolean create = cmdline.hasOption(CREATE_OPTION);
    IngestFiles load = new IngestFiles(name, create);
    load.ingestFolder(inputFolder, i);
  }
  private static Options createCommandLineOption() {
    Options options = new Options();

    Option accessKey = OptionBuilder.withArgName("AWS Access Key").hasArg().create("ak");

    Option secretKey = OptionBuilder.withArgName("AWS Secret Key").hasArg().create("sk");

    options.addOption(accessKey);
    options.addOption(secretKey);

    return options;
  }
  /** @return an {@link Option} object containing the available command line options for ProB 2.0 */
  @SuppressWarnings("static-access")
  @Provides
  public final Options getCommandlineOptions() {
    Options options = new Options();
    Option shell = new Option("s", "shell", false, "start ProB's Groovy shell");

    Option restricted =
        new Option("local", "Free access to Groovy shell. Interface will be bound to 127.0.0.1");

    Option standalone = new Option("standalone", "Run in standalone mode");

    Option animation =
        new Option(
            "multianimation",
            "UI components will have the capability to show multiple animations"
                + " at once (NOTE: the development of this option is in the"
                + " experimental phase)");

    Option maxCacheSize =
        OptionBuilder.withArgName("maxSize")
            .hasArg()
            .withDescription("set the cache size for the states in the StateSpace")
            .create("maxCacheSize");

    Option browser =
        OptionBuilder.withArgName("url")
            .hasArg()
            .withDescription("Open URL in browser")
            .create("browser");

    Option port =
        OptionBuilder.withArgName("port")
            .hasArg()
            .withDescription("Set specific port for UI")
            .create("port");

    // TODO: add modelchecking option
    // Option modelcheck = new Option("mc", "modelcheck", false,
    // "start ProB model checking");
    OptionGroup mode = new OptionGroup();
    mode.setRequired(true);
    // mode.addOption(modelcheck);
    mode.addOption(shell);
    options.addOptionGroup(mode);
    options.addOption(browser);
    options.addOption(port);
    options.addOption(restricted);
    options.addOption(standalone);
    options.addOption(animation);
    options.addOption(maxCacheSize);
    return options;
  }
Exemple #16
0
  @SuppressWarnings("static-access")
  private CommandLine parseArgs(String[] args) throws Exception {
    options = new Options();
    options.addOption(
        OptionBuilder.withDescription("path to output of pwsim algorithm")
            .withArgName("path")
            .hasArg()
            .isRequired()
            .create(PWSIM_OPTION));
    options.addOption(
        OptionBuilder.withDescription("path to output")
            .withArgName("path")
            .hasArg()
            .isRequired()
            .create(OUTPUT_PATH_OPTION));
    options.addOption(
        OptionBuilder.withDescription("source-side raw collection path")
            .withArgName("path")
            .hasArg()
            .isRequired()
            .create(FCOLLECTION_OPTION));
    options.addOption(
        OptionBuilder.withDescription("target-side raw collection path")
            .withArgName("path")
            .hasArg()
            .isRequired()
            .create(ECOLLECTION_OPTION));
    options.addOption(
        OptionBuilder.withDescription("two-letter code for f-language")
            .withArgName("en|de|tr|cs|zh|ar|es")
            .hasArg()
            .isRequired()
            .create(FLANG_OPTION));
    options.addOption(
        OptionBuilder.withDescription("two-letter code for e-language")
            .withArgName("en|de|tr|cs|zh|ar|es")
            .hasArg()
            .isRequired()
            .create(ELANG_OPTION));
    options.addOption(
        OptionBuilder.withDescription("only keep pairs that match these docnos")
            .withArgName("path to sample docnos file")
            .hasArg()
            .create(SAMPLEDOCNOS_OPTION));
    options.addOption(
        OptionBuilder.withDescription("Hadoop option to load external jars")
            .withArgName("jar packages")
            .hasArg()
            .create(LIBJARS_OPTION));

    CommandLine cmdline;
    CommandLineParser parser = new GnuParser();
    try {
      cmdline = parser.parse(options, args);
    } catch (ParseException exp) {
      System.err.println("Error parsing command line: " + exp.getMessage());
      return null;
    }
    return cmdline;
  }
  private void createOptions() {
    options = new Options();
    options.addOption("h", "help", false, "prints this message");
    options.addOption(
        "v", "validate", false, "parses xml input file for validation (without simulation)");
    options.addOption(
        "w",
        "write xsd",
        false,
        "writes xsd file to output (for convenience/lookup schema definitions)");
    options.addOption(
        "l",
        "log",
        false,
        "writes the file \"log4j.properties\" to file to adjust the logging properties on an individual level");

    OptionBuilder.withArgName("file");
    OptionBuilder.hasArg();
    ProjectMetaData.getInstance();
    OptionBuilder.withDescription(
        "movsim main configuration file (ending \""
            + ProjectMetaData.getMovsimConfigFileEnding()
            + "\" will be added automatically if not provided.");
    final Option xmlSimFile = OptionBuilder.create("f");
    options.addOption(xmlSimFile);

    OptionBuilder.withArgName("directory");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("argument is the output path relative to calling directory");
    final Option outputPathOption = OptionBuilder.create("o");
    options.addOption(outputPathOption);
  }
Exemple #18
0
 @SuppressWarnings("static-access")
 private static void addKeyOptions(Options opts) {
   opts.addOption(
       OptionBuilder.hasArgs()
           .withArgName("attr=value")
           .withValueSeparator('=')
           .withDescription(rb.getString("match"))
           .create("m"));
   opts.addOption(
       OptionBuilder.hasArgs()
           .withArgName("attr")
           .withDescription(rb.getString("in-attr"))
           .create("i"));
 }
 private Option runtimePath() {
   return OptionBuilder.withArgName("path")
       .hasArg()
       .withDescription(
           "where to find Redline. Defaults to environment " + REDLINE_HOME_ENVVAR + ".")
       .create(RUNTIMEPATH_OPTION);
 }
  public void test1(String[] args) {
    Option recursive =
        OptionBuilder.withArgName("recursive").withDescription("delete recursively").create("r");

    Options rmOption = new Options();
    rmOption.addOption(recursive);

    boolean recursiveOpt = false;

    CommandLineParser parser = new GnuParser();
    try {
      CommandLine line = parser.parse(rmOption, args);

      List<String> argsList = line.getArgList();
      System.out.println(argsList.size());

      try {
        if (line.hasOption("r")) {
          System.out.println("--");
          recursiveOpt = true;
        }
      } catch (Exception e) {
      }
    } catch (ParseException exp) {
    }
  }
 @SuppressWarnings("static-access")
 private Option createTodayOption() {
   return OptionBuilder.isRequired(false)
       .withDescription("Return if today is a holiday")
       .withLongOpt("today")
       .create("t");
 }
Exemple #22
0
  public void test11458() {
    Options options = new Options();
    options.addOption(OptionBuilder.withValueSeparator('=').hasArgs().create('D'));
    options.addOption(OptionBuilder.withValueSeparator(':').hasArgs().create('p'));
    String[] args = new String[] {"-DJAVA_HOME=/opt/java", "-pfile1:file2:file3"};

    CommandLineParser parser = new PosixParser();

    try {
      CommandLine cmd = parser.parse(options, args);

      String[] values = cmd.getOptionValues('D');

      assertEquals(values[0], "JAVA_HOME");
      assertEquals(values[1], "/opt/java");

      values = cmd.getOptionValues('p');

      assertEquals(values[0], "file1");
      assertEquals(values[1], "file2");
      assertEquals(values[2], "file3");

      java.util.Iterator iter = cmd.iterator();
      while (iter.hasNext()) {
        Option opt = (Option) iter.next();
        switch (opt.getId()) {
          case 'D':
            assertEquals(opt.getValue(0), "JAVA_HOME");
            assertEquals(opt.getValue(1), "/opt/java");
            break;
          case 'p':
            assertEquals(opt.getValue(0), "file1");
            assertEquals(opt.getValue(1), "file2");
            assertEquals(opt.getValue(2), "file3");
            break;
          default:
            fail("-D option not found");
        }
      }
    } catch (ParseException exp) {
      fail(
          "Unexpected Exception:\nMessage:"
              + exp.getMessage()
              + "Type: "
              + exp.getClass().getName());
    }
  }
  /** Specify properties of each generic option */
  @SuppressWarnings("static-access")
  private static Options buildGeneralOptions(Options opts) {
    Option fs =
        OptionBuilder.withArgName("local|namenode:port")
            .hasArg()
            .withDescription("specify a namenode")
            .create("fs");
    Option jt =
        OptionBuilder.withArgName("local|jobtracker:port")
            .hasArg()
            .withDescription("specify a job tracker")
            .create("jt");
    Option oconf =
        OptionBuilder.withArgName("configuration file")
            .hasArg()
            .withDescription("specify an application configuration file")
            .create("conf");
    Option property =
        OptionBuilder.withArgName("property=value")
            .hasArg()
            .withDescription("use value for given property")
            .create('D');
    Option libjars =
        OptionBuilder.withArgName("paths")
            .hasArg()
            .withDescription("comma separated jar files to include in the classpath.")
            .create("libjars");
    Option files =
        OptionBuilder.withArgName("paths")
            .hasArg()
            .withDescription("comma separated files to be copied to the " + "map reduce cluster")
            .create("files");
    Option archives =
        OptionBuilder.withArgName("paths")
            .hasArg()
            .withDescription(
                "comma separated archives to be unarchived" + " on the compute machines.")
            .create("archives");

    // file with security tokens
    Option tokensFile =
        OptionBuilder.withArgName("tokensFile")
            .hasArg()
            .withDescription("name of the file with the tokens")
            .create("tokenCacheFile");

    opts.addOption(fs);
    opts.addOption(jt);
    opts.addOption(oconf);
    opts.addOption(property);
    opts.addOption(libjars);
    opts.addOption(files);
    opts.addOption(archives);
    opts.addOption(tokensFile);

    return opts;
  }
  public void addParameterInfo() {

    /* use Object parameter of Options class to store parameter information */

    parameter.addOption(
        OptionBuilder.withArgName("input VCF file")
            .hasArg()
            .withDescription("Input vcf file containing variation info")
            .create(INPUT_VCF));

    parameter.addOption(
        OptionBuilder.withArgName("input tabular file")
            .hasArg()
            .withDescription("Input tabular file containing variation info")
            .create(INPUT_TAB));

    parameter.addOption(
        OptionBuilder.withArgName("output file")
            .hasArg()
            .withDescription("Output alleles p value")
            .create(OUTPUT_LINE));

    parameter.addOption(
        OptionBuilder.withArgName("Columns for Alleles")
            .hasArg()
            .withDescription("columns where allele info is set")
            .create(COLUMN));

    parameter.addOption(
        OptionBuilder.withArgName("Cache data")
            .hasArg(false)
            .withDescription("weather to cache data in memory or not, default no")
            .create(CACHE));

    parameter.addOption(
        OptionBuilder.withArgName("re-partition num")
            .hasArg()
            .withDescription(
                "even the load of each task, 1 partition for a task or 4 partitions for a task is recommended. Default, not re-partition")
            .create(PARTITIONS));

    parameter.addOption(
        OptionBuilder.hasArg(false).withDescription("show version information").create(VERSION));

    parameter.addOption(
        OptionBuilder.hasArg(false)
            .withDescription("print and show this information")
            .create(HELP));

    parameter.addOption(OptionBuilder.hasArg(false).withDescription("").create(HELP2));
  }
 @SuppressWarnings("static-access")
 public MigrateConstraintUKFunction() {
   this.addOption(
       OptionBuilder.withDescription("migrate Forgein Constraint.")
           .withLongOpt("name")
           .hasArg()
           .create("name"));
 }
Exemple #26
0
 @SuppressWarnings("static-access")
 private static void addRetrieveLevelOption(Options opts) {
   opts.addOption(
       OptionBuilder.hasArg()
           .withArgName("PATIENT|STUDY|SERIES|IMAGE|FRAME")
           .withDescription(rb.getString("level"))
           .create("L"));
 }
 @SuppressWarnings("static-access")
 private Option createVerboseOption() {
   return OptionBuilder.isRequired(false)
       .hasArg(false)
       .withDescription("Verbose output")
       .withLongOpt("verbose")
       .create("v");
 }
 /**
  * Convenience method to create a command line option with parameter.
  *
  * @param shortOpt The short form of the option (e. g. 'h' for '-h').
  * @param longOpt The long option text (e. g. 'help' for '--help').
  * @param desc The description used when printing the usage information.
  * @param argName The name of the argument holding the parameter information.
  * @return An Option object.
  */
 protected static Option createOption(
     String shortOpt, String longOpt, String desc, String argName) {
   return OptionBuilder.withArgName(argName)
       .hasArg()
       .withDescription(desc)
       .withLongOpt(longOpt)
       .create(shortOpt);
 }
 /** @param args */
 @SuppressWarnings("static-access")
 public static void main(String args[]) throws ParseException, IOException {
   Options options = new Options();
   options.addOption(
       OptionBuilder.withArgName("prop")
           .hasArg()
           .isRequired()
           .withDescription("property file with queries and other parameters. todo desc")
           .create("prop"));
   OptionGroup og = new OptionGroup();
   og.addOption(
       OptionBuilder.withArgName("prefix")
           .hasArg()
           .withDescription(
               "create network using specified concept graph and corpus. creates prefix.sif with edges and prefix.node.txt with node data in working directory.")
           .create("network"));
   og.addOption(
       OptionBuilder.withArgName("concept id")
           .hasArg()
           .withDescription(
               "get all descendants of specified concept, creates concept_id.tree file in working directory")
           .create("subtree"));
   og.setRequired(true);
   options.addOptionGroup(og);
   try {
     CommandLineParser parser = new GnuParser();
     CommandLine line = parser.parse(options, args);
     CytoscapeHelper cytHelper =
         KernelContextHolder.getApplicationContext().getBean(CytoscapeHelper.class);
     Properties props = FileUtil.loadProperties(line.getOptionValue("prop"), true);
     if (!cytHelper.validateProps(props)) {
       printHelp(options);
     } else {
       if (line.hasOption("network")) {
         cytHelper.exportNetwork(line.getOptionValue("network"), props);
       } else if (line.hasOption("subtree")) {
         cytHelper.exportSubtree(line.getOptionValue("subtree"), props);
       } else {
         printHelp(options);
       }
     }
   } catch (ParseException pe) {
     printHelp(options);
   }
 }
Exemple #30
0
  private static Options createOptions() {
    Options options = new Options();

    OptionBuilder.withDescription("Show this help");
    options.addOption(OptionBuilder.create(CMD_HELP));

    OptionBuilder.withArgName("port");
    OptionBuilder.hasOptionalArg();
    OptionBuilder.withDescription("The port to run the Nutch Server. Default port 8081");
    options.addOption(OptionBuilder.create(CMD_PORT));

    OptionBuilder.withArgName("host");
    OptionBuilder.hasOptionalArg();
    OptionBuilder.withDescription("The host to bind the Nutch Server to. Default is localhost.");
    options.addOption(OptionBuilder.create(CMD_PORT));

    return options;
  }