コード例 #1
0
ファイル: MainIT.java プロジェクト: difi/oxalis
  @Test
  public void testGetOptionParser() throws Exception {
    OptionParser optionParser = Main.getOptionParser();

    String tmpDir = systemTempDir().toString();

    OptionSet optionSet =
        optionParser.parse(
            "-f",
            "/tmp/dummy",
            "-s",
            "9908:976098897",
            "-r",
            "9908:810017902",
            "-u",
            "https://ap.unit4.com",
            "-m",
            "as2",
            "-e",
            tmpDir);
    assertTrue(optionSet.has("u"));
    assertTrue(optionSet.has("f"));
    assertTrue(optionSet.has("e"));
    Object e = optionSet.valueOf("e");
    assertNotNull(e);
    assertTrue(e instanceof File);
    File f = (File) e;
    assertEquals(f, new File(tmpDir));
  }
コード例 #2
0
  public static void main(String[] args) throws Exception {

    OptionParser parser = new OptionParser();
    parser
        .accepts("client-zone-id", "client zone id for zone routing")
        .withRequiredArg()
        .describedAs("zone-id")
        .ofType(Integer.class);
    OptionSet options = parser.parse(args);

    List<String> nonOptions = options.nonOptionArguments();
    if (nonOptions.size() < 2 || nonOptions.size() > 3) {
      System.err.println(
          "Usage: java VoldemortClientShell store_name bootstrap_url [command_file] [options]");
      parser.printHelpOn(System.err);
      System.exit(-1);
    }

    String storeName = nonOptions.get(0);
    String bootstrapUrl = nonOptions.get(1);

    String commandsFileName = "";
    BufferedReader fileReader = null;
    BufferedReader inputReader = null;
    try {
      if (nonOptions.size() == 3) {
        commandsFileName = nonOptions.get(2);
        fileReader = new BufferedReader(new FileReader(commandsFileName));
      }

      inputReader = new BufferedReader(new InputStreamReader(System.in));
    } catch (IOException e) {
      Utils.croak("Failure to open input stream: " + e.getMessage());
    }

    ClientConfig clientConfig =
        new ClientConfig()
            .setBootstrapUrls(bootstrapUrl)
            .setRequestFormatType(RequestFormatType.VOLDEMORT_V3);

    if (options.has("client-zone-id")) {
      clientConfig.setClientZoneId((Integer) options.valueOf("client-zone-id"));
    }

    StoreClientFactory factory = new SocketStoreClientFactory(clientConfig);

    try {
      client = (DefaultStoreClient<Object, Object>) factory.getStoreClient(storeName);
    } catch (Exception e) {
      Utils.croak("Could not connect to server: " + e.getMessage());
    }

    System.out.println("Established connection to " + storeName + " via " + bootstrapUrl);
    System.out.print(PROMPT);
    if (fileReader != null) {
      processCommands(factory, fileReader, true);
      fileReader.close();
    }
    processCommands(factory, inputReader, false);
  }
コード例 #3
0
ファイル: TrimAllReads.java プロジェクト: kyocum/seqware
  /**
   * {@inheritDoc}
   *
   * <p>All necessary setup for the module. Populate the "processing" table in seqware_meta_db.
   * Create a temporary directory.
   */
  @Override
  public ReturnValue init() {

    ReturnValue ret = new ReturnValue();
    ret.setExitStatus(ReturnValue.SUCCESS);
    // fill in the [xxx] fields in the processing table
    ret.setAlgorithm("TrimAllReads");
    ret.setDescription("Trim all reads to a specific length.");
    ret.setVersion("0.7.0");

    try {
      OptionParser parser = getOptionParser();
      // The parameters object is actually an ArrayList of Strings created
      // by splitting the command line options by space. JOpt expects a String[]
      options = parser.parse(this.getParameters().toArray(new String[0]));
      // create a temp directory in current working directory
      // tempDir = FileTools.createTempDirectory(new File("."));
      // you can write to "stdout" or "stderr" which will be persisted back to the DB
      ret.setStdout(ret.getStdout() + "Output: " + (String) options.valueOf("outfastq") + "\n");
    } catch (OptionException e) {
      e.printStackTrace();
      ret.setStderr(e.getMessage());
      ret.setExitStatus(ReturnValue.INVALIDPARAMETERS);
    } // catch (IOException e) {
    //  e.printStackTrace();
    //  ret.setStderr(e.getMessage());
    //  ret.setExitStatus(ReturnValue.DIRECTORYNOTWRITABLE);
    // }

    return (ret);
  }
コード例 #4
0
  @Test
  public void supportsPosixlyCorrectBehavior() {
    OptionParser parser = new OptionParser("i:j::k");
    String[] arguments = {
      "-ibar", "-i", "junk", "xyz", "-jixnay", "foo", "-k", "blah", "--", "bah"
    };

    OptionSet options = parser.parse(arguments);

    assertTrue(options.has("i"));
    assertTrue(options.has("j"));
    assertTrue(options.has("k"));
    assertEquals(asList("bar", "junk"), options.valuesOf("i"));
    assertEquals(singletonList("ixnay"), options.valuesOf("j"));
    assertEquals(asList("xyz", "foo", "blah", "bah"), options.nonOptionArguments());

    parser.posixlyCorrect(true);
    options = parser.parse(arguments);

    assertTrue(options.has("i"));
    assertFalse(options.has("j"));
    assertFalse(options.has("k"));
    assertEquals(asList("bar", "junk"), options.valuesOf("i"));
    assertEquals(emptyList(), options.valuesOf("j"));
    assertEquals(
        asList("xyz", "-jixnay", "foo", "-k", "blah", "--", "bah"), options.nonOptionArguments());
  }
コード例 #5
0
  /**
   * This is the main interface to ConfigurationOptions. Passing in the arguments array will return
   * an object containing all parsed arguments and default values for arguments not specified
   *
   * @param args the arguments array from <code>main(String[] args)</code>.
   * @return A set of configuration options.
   * @throws Exception
   */
  static ConfigurationOptions parse(String[] args) throws Exception {
    ConfigurationOptions cfg = new ConfigurationOptions();

    OptionParser parser = setupParser();
    processOptions(parser.parse(args), cfg);

    return cfg;
  }
コード例 #6
0
ファイル: MainIT.java プロジェクト: difi/oxalis
  @Test
  public void senderAndReceiverIsOptional() throws Exception {
    OptionParser optionParser = Main.getOptionParser();

    OptionSet optionSet =
        optionParser.parse("-f", "/tmp/dummy", "-u", "https://ap.unit4.com", "-m", "as2");
    assertFalse(optionSet.has("-r"));
    assertFalse(optionSet.has("-s"));
  }
コード例 #7
0
ファイル: AuthNTest.java プロジェクト: modulexcite/oscars
  public static void parseArgs(String args[]) throws java.io.IOException {

    parser.acceptsAll(asList("h", "?"), "show help then exit");
    OptionSpec<String> CMD = parser.accepts("c", "command").withRequiredArg().ofType(String.class);
    OptionSpec<String> LOGIN =
        parser.accepts("u", "LoginId").withRequiredArg().ofType(String.class);
    OptionSpec<String> PASSWORD =
        parser.accepts("p", "password").withRequiredArg().ofType(String.class);
    OptionSpec<String> ISSUER =
        parser.accepts("i", "IssuerDN").withRequiredArg().ofType(String.class);
    OptionSpec<String> SUBJECT =
        parser.accepts("s", "SubjectDN").withRequiredArg().ofType(String.class);
    OptionSpec<String> CONTEXT =
        parser
            .accepts("C", "context:UNITTEST,DEVELOPMENT,SDK,PRODUCTION")
            .withRequiredArg()
            .ofType(String.class);

    OptionSet options = parser.parse(args);

    // check for help
    if (options.has("?")) {
      parser.printHelpOn(System.out);
      System.exit(0);
    }
    if (options.has(CMD)) {
      cmd = options.valueOf(CMD);
    } else {
      System.out.println("a -c cmd argument is required");
      parser.printHelpOn(System.out);
      System.exit(0);
    }
    if (options.has(LOGIN)) {
      loginName = options.valueOf(LOGIN);
    }
    if (options.has(PASSWORD)) {
      password = options.valueOf(PASSWORD);
    }
    if (options.has(ISSUER)) {
      issuer = options.valueOf(ISSUER);
    }
    if (options.has(SUBJECT)) {
      subject = options.valueOf(SUBJECT);
    }
    if (options.has(CONTEXT)) {
      context = options.valueOf(CONTEXT);
      if (!context.equals("UNITTEST")
          && !context.equals("SDK")
          && !context.equals("DEVELOPMENT")
          && !context.equals("PRODUCTION")) {
        System.out.println("unrecognized CONTEXT value: " + context);
        System.exit(-1);
      }
    }
  }
コード例 #8
0
ファイル: Runner.java プロジェクト: raiben/made
 private OptionParser buildOptionParser() {
   OptionParser parser = new OptionParser();
   parser
       .accepts(ARGUMENT_EXPERIMENT, "Pre selected experiment")
       .withRequiredArg()
       .ofType(String.class);
   parser.accepts(ARGUMENT_EXPERIMENT_LIST, "Retrieves the current list of available experiments");
   parser.accepts(ARGUMENT_HELP, "Displays this help").forHelp();
   parser.allowsUnrecognizedOptions();
   return parser;
 }
コード例 #9
0
ファイル: TrimAllReads.java プロジェクト: kyocum/seqware
 /**
  * {@inheritDoc}
  *
  * <p>A method used to return the syntax for this module
  */
 @Override
 public String get_syntax() {
   OptionParser parser = getOptionParser();
   StringWriter output = new StringWriter();
   try {
     parser.printHelpOn(output);
     return (output.toString());
   } catch (IOException e) {
     e.printStackTrace();
     return (e.getMessage());
   }
 }
コード例 #10
0
ファイル: MaintenanceCommand.java プロジェクト: kkjslee/hqapi
  private void unschedule(String[] args) throws Exception {
    String[] ONE_REQUIRED = {OPT_RESOURCEID, OPT_GROUPID};

    OptionParser p = getOptionParser();

    p.accepts(OPT_RESOURCEID, "The id of the resource to unschedule from maintenance")
        .withRequiredArg()
        .ofType(Integer.class);

    p.accepts(OPT_GROUPID, "The id of the group to unschedule from maintenance")
        .withRequiredArg()
        .ofType(Integer.class);

    OptionSet options = getOptions(p, args);

    int criteria = 0;
    for (String opt : ONE_REQUIRED) {
      if (options.has(opt)) {
        criteria++;
      }
    }

    if (criteria == 0) {
      System.err.println("One of " + Arrays.toString(ONE_REQUIRED) + " is required.");
      System.exit(-1);
    } else if (criteria > 1) {
      System.err.println("Only one of " + Arrays.toString(ONE_REQUIRED) + " may be specified");
      System.exit(-1);
    }

    HQApi api = getApi(options);
    MaintenanceApi maintenanceApi = api.getMaintenanceApi();
    StatusResponse response = null;
    Integer id = null;

    if (options.has(OPT_GROUPID)) {
      id = (Integer) getRequired(options, OPT_GROUPID);
      response = maintenanceApi.unschedule(id);
    } else if (options.has(OPT_RESOURCEID)) {
      id = (Integer) getRequired(options, OPT_RESOURCEID);
      ResourceResponse resourceResponse = api.getResourceApi().getResource(id, false, false);
      checkSuccess(resourceResponse);
      response = maintenanceApi.unschedule(resourceResponse.getResource());
    }

    checkSuccess(response);

    if (options.has(OPT_GROUPID)) {
      System.out.println("Maintenance for group " + id + " unscheduled.");
    } else {
      System.out.println("Maintenance for resource " + id + " unscheduled.");
    }
  }
コード例 #11
0
  @Test
  public void allowsDifferentFormsOfPairingArgumentWithOption() {
    OptionParser parser = new OptionParser();
    parser.accepts("count").withRequiredArg();
    parser.accepts("level").withOptionalArg();

    OptionSet options = parser.parse("--count", "4", "--level=3");

    assertTrue(options.has("count"));
    assertTrue(options.hasArgument("count"));
    assertEquals("4", options.valueOf("count"));

    assertTrue(options.has("level"));
    assertTrue(options.hasArgument("level"));
    assertEquals("3", options.valueOf("level"));
  }
コード例 #12
0
  @Test
  public void supportsOptionSynonyms() {
    OptionParser parser = new OptionParser();
    List<String> synonyms = asList("message", "blurb", "greeting");
    parser.acceptsAll(synonyms).withRequiredArg();
    String expectedMessage = "Hello";

    OptionSet options = parser.parse("--message", expectedMessage);

    for (String each : synonyms) {
      assertTrue(each, options.has(each));
      assertTrue(each, options.hasArgument(each));
      assertEquals(each, expectedMessage, options.valueOf(each));
      assertEquals(each, asList(expectedMessage), options.valuesOf(each));
    }
  }
コード例 #13
0
ファイル: AdminTest.java プロジェクト: Benoye/voldemort
 public static void printUsage(PrintStream out, OptionParser parser, String msg)
     throws IOException {
   out.println(msg);
   out.println(usageStr);
   parser.printHelpOn(out);
   System.exit(1);
 }
コード例 #14
0
 private static void printHelp(OptionParser parser) {
   try {
     parser.printHelpOn(System.out);
   } catch (Exception exception) {
     exception.printStackTrace();
   }
 }
コード例 #15
0
  @Override
  protected void customizeOptionParsing(OptionParser parser) {
    parser
        .accepts(USER_DATA_DIR_KEY, description("User data directory", DEFAULT_USER_DATA_DIR))
        .withRequiredArg();
    parser
        .accepts(APP_NAME_KEY, description("Application name", DEFAULT_APP_NAME))
        .withRequiredArg();
    parser
        .accepts(APP_DATA_DIR_KEY, description("Application data directory", DEFAULT_APP_DATA_DIR))
        .withRequiredArg();
    parser
        .acceptsAll(
            asList(APP_DATA_DIR_CLEAN_KEY, "clean"),
            description("Clean application data directory", DEFAULT_APP_DATA_DIR_CLEAN))
        .withRequiredArg()
        .ofType(boolean.class);
    parser
        .accepts(ProgramArguments.NAME_KEY, description("Name of this node", null))
        .withRequiredArg();
    // use a fixed port as arbitrator use that for his ID
    parser
        .accepts(ProgramArguments.PORT_KEY, description("Port to listen on", 9999))
        .withRequiredArg()
        .ofType(int.class);
    parser
        .accepts(
            ProgramArguments.USE_LOCALHOST,
            description("Use localhost network for development", false))
        .withRequiredArg()
        .ofType(boolean.class);
    parser
        .accepts(ProgramArguments.DEV_TEST, description("Enable arbitrator dev priv key", false))
        .withRequiredArg()
        .ofType(boolean.class);
    parser
        .accepts(BitcoinNetwork.KEY, description("Bitcoin network", BitcoinNetwork.DEFAULT))
        .withRequiredArg()
        .ofType(BitcoinNetwork.class)
        .withValuesConvertedBy(new EnumValueConverter(BitcoinNetwork.class));

    parser
        .accepts(RegTestHost.KEY, description("", RegTestHost.DEFAULT))
        .withRequiredArg()
        .ofType(RegTestHost.class)
        .withValuesConvertedBy(new EnumValueConverter(RegTestHost.class));
  }
コード例 #16
0
ファイル: Benchmark.java プロジェクト: rzs840707/mile
 private static void printUsage(OptionParser parser, String errorCommand) throws IOException {
   parser.printHelpOn(System.err);
   Utils.croak(
       "Usage: $MILE_HOME/bin/run-class.sh "
           + Benchmark.class.getName()
           + " [options] config-file ops-count\n "
           + errorCommand);
 }
コード例 #17
0
 private OptionSet parseOptions(OptionParser p, String[] args) throws IOException {
   OptionSet options = null;
   try {
     options = p.parse(args);
     if (options.has("?")
         || !options.has(maxwiOptName)
         || options.nonOptionArguments().size() < 2) {
       System.err.println("Usage:\nSimilarity <input_paths> <output_path> [options]");
       System.err.println("Please specify " + maxwiOptName + " option\n");
       p.printHelpOn(System.err);
       System.exit(0);
     }
   } catch (OptionException e) {
     System.err.println(e.getMessage());
     System.exit(1);
   }
   return options;
 }
コード例 #18
0
ファイル: Runner.java プロジェクト: raiben/made
 private void printHelp(OptionParser parser) {
   try {
     ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
     parser.printHelpOn(byteArrayOutputStream);
     System.out.println(byteArrayOutputStream.toString());
   } catch (IOException ex) {
     Logger.getLogger(Runner.class.getName()).log(Level.SEVERE, null, ex);
   }
 }
コード例 #19
0
  @Test
  public void testInitOptionsWithHelp_optionalArgument() {
    parser.accepts("argName", "Funky description");

    OptionSet options = initOptionsWithHelp(parser, new String[] {"--argName"});
    assertNotNull(options);
    assertEquals(1, options.specs().size());
    assertTrue(options.has("argName"));
  }
コード例 #20
0
  public final void parseAndExecute(final String[] cmds) throws IOException {
    opts = parser.parse(cmds);
    if (opts.has(HELP)) {
      parser.printHelpOn(System.out);
      return;
    }

    Indexing.STORE = opts.has(STORE);
    Indexing.COMMIT = (Integer) opts.valueOf(COMMIT);

    // FORMAT
    if (opts.has(FORMAT)) {
      format = (Format) opts.valueOf(FORMAT);
    } else printError(FORMAT);

    // DUMPS_DIR
    if (opts.has(DUMPS_DIR)) {
      dumpsDir = (File) opts.valueOf(DUMPS_DIR);
    } else printError(DUMPS_DIR);

    // INDEX_DIR
    if (opts.has(INDEX_DIR)) {
      indexDir = (File) opts.valueOf(INDEX_DIR);
    } else printError(INDEX_DIR);

    logger.info(
        "Creating index at {} from the files at {}",
        indexDir.getAbsolutePath(),
        dumpsDir.getAbsolutePath());
    final Indexing indexing;
    switch (format) {
      case SINDICE_DE:
        indexing = new SindiceDEIndexing(dumpsDir, FSDirectory.open(indexDir));
        break;
      case SINDICE_ED:
        indexing = new SindiceEDIndexing(dumpsDir, FSDirectory.open(indexDir));
        break;
      default:
        throw new IllegalArgumentException("No such dataset format: " + format);
    }
    indexing.indexIt();
    indexing.close();
    logger.info("Finished indexing");
  }
コード例 #21
0
  @Test(expected = CommandLineExitException.class)
  public void testInitOptionsWithHelp_missingArgument() {
    parser
        .accepts("argName", "Funky description")
        .withRequiredArg()
        .ofType(String.class)
        .defaultsTo("nope");

    initOptionsWithHelp(parser, new String[] {"--argName"});
  }
コード例 #22
0
ファイル: ProtoBackend.java プロジェクト: newsky/sparrow
  public static void main(String[] args) throws IOException, TException {
    OptionParser parser = new OptionParser();
    parser.accepts("c", "configuration file").withRequiredArg().ofType(String.class);
    parser.accepts("help", "print help statement");
    OptionSet options = parser.parse(args);

    if (options.has("help")) {
      parser.printHelpOn(System.out);
      System.exit(-1);
    }

    // Logger configuration: log to the console
    BasicConfigurator.configure();
    LOG.setLevel(Level.DEBUG);
    LOG.debug("debug logging on");

    Configuration conf = new PropertiesConfiguration();

    if (options.has("c")) {
      String configFile = (String) options.valueOf("c");
      try {
        conf = new PropertiesConfiguration(configFile);
      } catch (ConfigurationException e) {
      }
    }
    // Start backend server
    BackendService.Processor<BackendService.Iface> processor =
        new BackendService.Processor<BackendService.Iface>(new ProtoBackend());

    int listenPort = conf.getInt("listen_port", DEFAULT_LISTEN_PORT);
    NM_PORT = conf.getInt("node_monitor_port", NodeMonitorThrift.DEFAULT_NM_THRIFT_PORT);
    TServers.launchThreadedThriftServer(listenPort, THRIFT_WORKER_THREADS, processor);

    // Register server
    client = TClients.createBlockingNmClient(NM_HOST, NM_PORT);

    try {
      client.registerBackend(APP_ID, "localhost:" + listenPort);
      LOG.debug("Client successfullly registered");
    } catch (TTransportException e) {
      LOG.debug("Error while registering backend: " + e.getMessage());
    }
  }
コード例 #23
0
 private static void checkRequiredArgs(
     OptionParser parser, OptionSet options, OptionSpec[] required) throws IOException {
   for (OptionSpec arg : required) {
     if (!options.has(arg)) {
       System.err.println("Missing required argument \"" + arg + "\"");
       parser.printHelpOn(System.err);
       System.exit(1);
     }
   }
 }
コード例 #24
0
ファイル: SaraTouchClient.java プロジェクト: paulmelis/colt
  public static void main(String[] args) throws Exception {
    SaraTouchClient client = new SaraTouchClient();

    OptionParser parser = new OptionParser("ch:p:t");
    OptionSet options = null;

    try {
      options = parser.parse(args);
    } catch (Exception e) {
      System.out.println("Could not parse command-line options:\n" + e);
      System.out.println();
      System.out.println("-h <host>   Server host");
      System.out.println("-p <port>   Server port");
      System.out.println("-t          Send TUIO events instead of mouse events");
      System.out.println("-c          Connect after starting up");
      System.out.println();
      System.exit(-1);
    }

    if (options.has("h")) {
      Object o = options.valueOf("h");
      if (o != null) {
        String s = (String) o;
        client.setHost(s);
      }
    }

    if (options.has("p")) {
      Object o = options.valueOf("p");
      if (o != null) {
        int i = Integer.parseInt((String) o);
        client.setPort(i);
      }
    }

    if (options.has("t")) client.setModeToTUIO();

    if (options.has("c")) client.connect();

    client.setSize(600, 500);
    client.setVisible(true);
  }
コード例 #25
0
 static void checkRequiredArgs(
     OptionParser parser, OptionSet options, OptionSpec<?>... optionSepcs) throws IOException {
   for (OptionSpec<?> arg : optionSepcs) {
     if (!options.has(arg)) {
       System.err.println("Missing required argument " + arg);
       // parser.formatHelpWith(new MyFormatter());
       parser.printHelpOn(System.err);
       System.exit(1);
     }
   }
 }
コード例 #26
0
  // For passing args in Netbeans 7.3, see http://forums.netbeans.org/ptopic46048.html. Doesn't work
  // as of 17-09-2013 (it is ignored).
  public static void main(String[] args) {
    EmmaBiblioJOB emmaBiblioJob = new EmmaBiblioJOB();
    int retVal = 0;
    OptionParser optionParser = new OptionParser();
    optionParser.accepts("a"); // validate all biblios.
    optionParser.accepts(
        "v"); // validate update candidate biblios (whose 'updated' flag is not 'Y').
    optionParser.accepts("u"); // update candidate biblios that pass validation.

    OptionSet options = optionParser.parse(args);
    if (options.has("a")) retVal = Math.max(retVal, emmaBiblioJob.validateAll());

    if (options.has("v")) retVal = Math.max(retVal, emmaBiblioJob.validateUpdateCandidates());

    if (options.has("u")) retVal = Math.max(retVal, emmaBiblioJob.update());

    if (!((options.has("a")) || (options.has("v")) || (options.has("u")))) usage();

    System.exit(retVal);
  }
コード例 #27
0
ファイル: jGnashFx.java プロジェクト: numinasthmatic/jgnash
  private static OptionParser buildParser() {
    final OptionParser parser =
        new OptionParser() {
          {
            acceptsAll(asList(HELP_OPTION_SHORT, HELP_OPTION_LONG), "This help").forHelp();
            acceptsAll(
                asList(UNINSTALL_OPTION_SHORT, UNINSTALL_OPTION_LONG), "Remove registry settings");
            acceptsAll(
                asList(VERBOSE_OPTION_SHORT, VERBOSE_OPTION_LONG),
                "Enable verbose application messages");
            acceptsAll(asList(FILE_OPTION_SHORT, FILE_OPTION_LONG), "File to load at start")
                .withRequiredArg()
                .ofType(File.class);
            accepts(PASSWORD_OPTION, "Password for a local File, server or client")
                .withRequiredArg();
            acceptsAll(
                asList(PORTABLE_OPTION_SHORT, PORTABLE_OPTION_LONG), "Enable portable preferences");
            accepts(PORTABLE_FILE_OPTION, "Enable portable preferences and specify the file")
                .withRequiredArg()
                .ofType(File.class);
            accepts(
                    PORT_OPTION,
                    "Network port server is running on (default: "
                        + JpaNetworkServer.DEFAULT_PORT
                        + ")")
                .withRequiredArg()
                .ofType(Integer.class);
            accepts(HOST_OPTION, "Server host name or address")
                .requiredIf(PORT_OPTION)
                .withRequiredArg();
            accepts(SERVER_OPTION, "Runs as a server using the specified file")
                .withRequiredArg()
                .ofType(File.class);
          }
        };

    parser.allowsUnrecognizedOptions();

    return parser;
  }
コード例 #28
0
ファイル: Runner.java プロジェクト: raiben/made
  public void run() {
    Reflections.log = null;

    printVersion();

    OptionParser parser = buildOptionParser();

    OptionSet options = parser.parse(arguments);
    if (options.has(ARGUMENT_EXPERIMENT)) {
      runExperiment(options.valueOf(ARGUMENT_EXPERIMENT).toString());
      System.exit(0);
    }
    if (options.has(ARGUMENT_EXPERIMENT_LIST)) {
      printExperimentList();
      System.exit(0);
    }
    if (options.has(ARGUMENT_HELP)) {
      printHelp(parser);
      System.exit(0);
    }
    printHelp(parser);
  }
コード例 #29
0
ファイル: Main.java プロジェクト: Muzietto/cli-java-prototype
  public static void main(String[] args) {
    OptionParser p = new OptionParser("fc:q::");
    p.accepts("ftp");
    p.accepts("user").requiredIf("ftp").withRequiredArg();
    p.accepts("pass").requiredIf("ftp").withRequiredArg();

    OptionSet opt = p.parse(args);
    if (opt.has("f")) {
      System.out.println("-f exist");
      System.out.println("-f with : " + opt.valueOf("f"));
    }
    if (opt.has("c")) {
      System.out.println("-c exist with:" + opt.valueOf("c"));
    }

    if (opt.has("ftp")) {
      // we know username and password
      // existe if -ftp is set
      String user = (String) opt.valueOf("user");
      String pwd = (String) opt.valueOf("pass");
      System.out.println("user:"******" pass:" + pwd);
    }
  }
コード例 #30
0
ファイル: TrimAllReads.java プロジェクト: kyocum/seqware
 /**
  * getOptionParser is an internal method to parse command line args.
  *
  * @return OptionParser this is used to get command line options
  */
 protected OptionParser getOptionParser() {
   OptionParser parser = new OptionParser();
   parser.accepts("infastq", "input: reads in fastq format").withRequiredArg();
   parser.accepts("outfastq", "output: trimmed reads in fastq format").withRequiredArg();
   parser.accepts("readsize", "length (in bases) of output reads").withRequiredArg();
   parser.accepts("perl", "Path to perl").withRequiredArg();
   parser.accepts("script", "Path to perl script: sw_module_TrimAllReads.pl").withRequiredArg();
   return (parser);
 }