コード例 #1
0
ファイル: TestTajoCli.java プロジェクト: jungkoo/tajo
  @Test
  public void testParseConf() throws Exception {
    String[] args =
        new String[] {
          "--conf",
          "tajo.cli.print.pause=false",
          "--conf",
          "tajo.executor.join.inner.in-memory-table-num=256"
        };

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(TajoCli.options, args);
    String[] confValues = cmd.getOptionValues("conf");

    assertNotNull(confValues);
    assertEquals(2, confValues.length);

    assertEquals("tajo.cli.print.pause=false", confValues[0]);
    assertEquals("tajo.executor.join.inner.in-memory-table-num=256", confValues[1]);

    TajoConf tajoConf = TpchTestBase.getInstance().getTestingCluster().getConfiguration();
    TajoCli testCli = new TajoCli(tajoConf, args, System.in, System.out);
    try {
      assertEquals("false", testCli.getContext().get(SessionVars.CLI_PAGING_ENABLED));
      assertEquals(
          "256",
          testCli.getContext().getConf().get("tajo.executor.join.inner.in-memory-table-num"));
    } finally {
      testCli.close();
    }
  }
コード例 #2
0
  private void processCommandLine(String[] args) throws ParseException {
    Option certificateFilenameOption;
    Options commandLineOptions;
    CommandLineParser clp;
    CommandLine cl;

    certificateFilenameOption = null;
    commandLineOptions = null;
    clp = null;
    cl = null;

    certificateFilenameOption =
        new Option("f", "file", true, "file name containing certificate to be imported");
    certificateFilenameOption.setRequired(true);
    certificateFilenameOption.setArgs(1);
    certificateFilenameOption.setOptionalArg(false);
    certificateFilenameOption.setArgName("filename");

    commandLineOptions = new Options();
    commandLineOptions.addOption(certificateFilenameOption);

    clp = new PosixParser();

    try {
      cl = clp.parse(commandLineOptions, args);

      setCertificateFilename(IMPORT_AREA_DIRECTORY + "/" + cl.getOptionValue('f'));
    } catch (ParseException pe) {
      HelpFormatter formatter = new HelpFormatter();

      formatter.printHelp(APPLICATION_NAME, commandLineOptions, true);

      throw pe;
    }
  }
コード例 #3
0
  public static final void main(String[] args) {
    String accessKey = null;
    String secretKey = null;

    Options options = createCommandLineOption();

    CommandLineParser parser = new GnuParser();
    try {
      // parse the command line arguments
      CommandLine line = parser.parse(options, args);

      if (!line.hasOption("ak")) {
        throw new ParseException("AWS Accress Key is missing.");
      }

      if (!line.hasOption("sk")) {
        throw new ParseException("AWS Secret Key is missing.");
      }

      accessKey = line.getOptionValue("ak");
      secretKey = line.getOptionValue("sk");

    } catch (ParseException exp) {
      System.err.println("Parsing failed.  Reason: " + exp.getMessage());
      System.exit(1);
    }

    TargetURLGenerator generator = new TargetURLGenerator();

    generator.setAccessKey(accessKey);
    generator.setSecretKey(secretKey);

    generator.run();
  }
コード例 #4
0
ファイル: Cli.java プロジェクト: difi/vefa-validator
  public static int perform(String... args) throws Exception {
    Options options = new Options();
    options.addOption("a", "artifacts", true, "Artifacts");
    options.addOption("x", "exitcode", false, "Status in exit code");

    CommandLineParser parser = new DefaultParser();
    final CommandLine cmd = parser.parse(options, args);

    List<Path> testFolders =
        new ArrayList<Path>() {
          {
            for (String arg : cmd.getArgs()) add(Paths.get(arg));
          }
        };

    String artifacts = cmd.getOptionValue("a", "https://vefa.difi.no/validator/repo/");
    List<Validation> validations;
    if (artifacts.startsWith("http"))
      validations = Tester.perform(URI.create(artifacts), testFolders);
    else validations = Tester.perform(Paths.get(artifacts), testFolders);

    int result = 0;
    if (cmd.hasOption("x"))
      for (Validation validation : validations)
        if (validation.getReport().getFlag().compareTo(FlagType.EXPECTED) > 0)
          result = Math.max(result, validation.getReport().getFlag().compareTo(FlagType.EXPECTED));

    return result;
  }
コード例 #5
0
  /**
   * *************************************************************************** {@link Runnable}
   * Interface **************************************************************************
   */
  public void run(String[] args) throws IOException {

    if (needsHelp(args)) {
      printHelp();
      System.exit(0);
    }

    try {
      CommandLine cli = _parser.parse(_options, args, true);
      runApplication(cli, args);
    } catch (MissingOptionException ex) {
      System.err.println("Missing argument: " + ex.getMessage());
      printHelp();
    } catch (MissingArgumentException ex) {
      System.err.println("Missing argument: " + ex.getMessage());
      printHelp();
    } catch (UnrecognizedOptionException ex) {
      System.err.println("Unknown argument: " + ex.getMessage());
      printHelp();
    } catch (AlreadySelectedException ex) {
      System.err.println("Argument already selected: " + ex.getMessage());
      printHelp();
    } catch (ParseException ex) {
      System.err.println(ex.getMessage());
      printHelp();
    } catch (TransformSpecificationException ex) {
      System.err.println("error with transform line: " + ex.getLine());
      System.err.println(ex.getMessage());
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #6
0
ファイル: BenchmarkBinary.java プロジェクト: mayr/exemplar
  public static void main(String[] rawArgs)
      throws FileNotFoundException, UnsupportedEncodingException {

    CommandLineParser parser = new BasicParser();

    Options options = new Options();
    options.addOption("p", "parser", true, "Which parser to use. (stanford | malt)");

    CommandLine line = null;

    try {
      line = parser.parse(options, rawArgs);
    } catch (ParseException exp) {
      System.err.println(exp.getMessage());
      System.exit(1);
    }

    String[] args = line.getArgs();
    String parserName = line.getOptionValue("parser", "stanford");

    System.out.println("Using " + parserName + " parser");

    File evaluationFile = new File(args[0]);
    File outputFile = new File(args[1]);

    BenchmarkBinary evaluation = new BenchmarkBinary(evaluationFile, outputFile, parserName);

    // read evaluation file with sentences annotated with golden statements
    // and run Exemplar over them.
    evaluation.runAndTime();
  }
コード例 #7
0
ファイル: BxDocRewriter.java プロジェクト: CeON/CERMINE
  public void run(String[] args)
      throws ParseException, TransformationException, IOException, AnalysisException {
    Options options = new Options();
    options.addOption("input", true, "input path");
    options.addOption("output", true, "output path");
    options.addOption("ext", true, "extension");
    CommandLineParser parser = new DefaultParser();
    CommandLine line = parser.parse(options, args);
    String inDir = line.getOptionValue("input");
    String outDir = line.getOptionValue("output");
    String extension = line.getOptionValue("ext");

    File dir = new File(inDir);

    for (File f : FileUtils.listFiles(dir, new String[] {extension}, true)) {
      TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
      List<BxPage> pages = tvReader.read(new FileReader(f));
      BxDocument doc = new BxDocument().setPages(pages);
      doc.setFilename(f.getName());

      BxDocument rewritten = transform(doc);

      File f2 = new File(outDir + doc.getFilename());
      BxDocumentToTrueVizWriter wrt = new BxDocumentToTrueVizWriter();
      boolean created = f2.createNewFile();
      if (!created) {
        throw new IOException("Cannot create file: ");
      }
      FileWriter fw = new FileWriter(f2);
      wrt.write(fw, Lists.newArrayList(rewritten));
      fw.flush();
      fw.close();
    }
  }
コード例 #8
0
  public static void main(String args[]) {
    File f = new File("resources/archive_hub_dump.nt");
    String name = f.getName();

    CommandLineParser parser = new BasicParser();
    CommandLine cmd;
    try {
      cmd = parser.parse(getCLIOptions(), args);
      if (cmd.hasOption("file")) {
        f = new File(cmd.getOptionValue("file"));
        if (!f.exists()) {
          System.err.println("File/Directory to compress not found.");
          System.exit(0);
        }
      }
      if (cmd.hasOption("name")) {
        name = cmd.getOptionValue("name");
      }
    } catch (ParseException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    HDTEvaluation hdtEval = new HDTEvaluation(name, f);

    try {
      hdtEval.run();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ParserException e) {
      e.printStackTrace();
    }
  }
コード例 #9
0
  /**
   * The main CLI processor
   *
   * @param args command line argument
   */
  public static void main(String[] args) {

    checkJavaVersion();
    String logConfig = System.getProperty("log4j.configuration");
    if (logConfig != null && logConfig.length() > 0) {
      File lc = new File(logConfig);
      if (lc.exists()) {
        PropertyConfigurator.configure(logConfig);
        Properties defaults = loadDefaults();
        try {
          Options o = getOptions();
          CommandLineParser parser = new GnuParser();
          CommandLine cmdline = parser.parse(o, args);
          GdcNotification gdi = new GdcNotification(cmdline, defaults);
          if (!gdi.finishedSucessfuly) {
            System.exit(1);
          }
        } catch (org.apache.commons.cli.ParseException e) {
          l.error("Error parsing command line parameters: " + e.getMessage());
          l.debug("Error parsing command line parameters", e);
        }
      } else {
        l.error(
            "Can't find the logging config. Please configure the logging via the log4j.configuration.");
      }
    } else {
      l.error(
          "Can't find the logging config. Please configure the logging via the log4j.configuration.");
    }
  }
コード例 #10
0
ファイル: Mib2Events.java プロジェクト: GerryStydy/opennms
  public void parseCli(String[] argv) {
    Options opts = new Options();
    opts.addOption("m", "mib", true, "Pathname or URL of MIB file to scan for traps");
    opts.addOption("b", "ueibase", true, "Base UEI for resulting events");
    opts.addOption(
        "c",
        "compat",
        false,
        "Turn on compatibility mode to create output as similar to mib2opennms as possible");

    CommandLineParser parser = new GnuParser();
    try {
      CommandLine cmd = parser.parse(opts, argv);
      if (cmd.hasOption('m')) {
        m_mibLocation = cmd.getOptionValue('m');
      } else {
        printHelp("You must specify a MIB file pathname or URL");
        System.exit(1);
      }
      if (cmd.hasOption("b")) {
        m_ueiBase = cmd.getOptionValue('b');
      }
      if (cmd.hasOption("c")) {
        m_compat = true;
      }
    } catch (ParseException e) {
      printHelp("Failed to parse command line options");
      System.exit(1);
    }
  }
コード例 #11
0
  /**
   * Processing the input command line arguments
   *
   * @param args a list of pride db accessions
   */
  private void processCmdArgs(String[] args) {
    try {
      // parse command line input
      CommandLine cmd = cmdParser.parse(cmdOptions, args);

      // get accessions
      java.util.List<Comparable> accs = null;
      if (cmd.hasOption(ACCESSION_CMD)) {
        String accStr = cmd.getOptionValue(ACCESSION_CMD);
        accs = new ArrayList<Comparable>(AccessionUtils.expand(accStr));
      }

      // get user name
      String username = null;
      if (cmd.hasOption(USER_NAME_CMD)) {
        username = cmd.getOptionValue(USER_NAME_CMD);
      }

      // get password
      String password = null;
      if (cmd.hasOption(PASSWORD_CMD)) {
        password = cmd.getOptionValue(PASSWORD_CMD);
      }

      if (accs != null || username != null) {
        OpenValidPrideExperimentTask task =
            new OpenValidPrideExperimentTask(accs, username, password);
        task.setGUIBlocker(new DefaultGUIBlocker(task, GUIBlocker.Scope.NONE, null));
        getDesktopContext().addTask(task);
      }
    } catch (ParseException e) {
      System.err.println("Parsing command line option failed. Reason: " + e.getMessage());
    }
  }
コード例 #12
0
ファイル: Cirrus.java プロジェクト: anukat2015/cumulusrdf
  /**
   * Cirrus main entry point.
   *
   * @param args the command line arguments.
   */
  public static void main(final String[] args) {

    if (args.length < 1) {
      LOG.error(MessageCatalog.WRONG_ARGS_SIZE);
      System.exit(1);
    }

    final Command command = COMMAND_REGISTRY.get(args[0]);
    if (command == null) {
      LOG.error(MessageCatalog._00001__UNKNOWN_COMMAND, args[0]);
      System.exit(1);
    }

    final CommandLineParser parser = new BasicParser();

    try {
      final CommandLine commandLine = parser.parse(command.getOptions(), args);
      command.execute(commandLine);
    } catch (final MissingOptionException exception) {
      command._log.error(MessageCatalog._00028_CL_PARSER_FAILURE, exception.getMessage());
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("cirrus <command> <options>", command.getOptions());
      System.exit(1);
    } catch (final ParseException exception) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("cirrus <command> <options>", command.getOptions());
      System.exit(1);
    }
  }
コード例 #13
0
ファイル: Main.java プロジェクト: StShadow/nest
  public static void main(String[] args) throws ConfigurationException, ParseException {
    Configuration config = new PropertiesConfiguration("application.properties");

    // Options
    Options options = setUpOptions();

    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(options, args);

    // TODO Anatoli: it makes sense to add strict validation
    for (Option option : cmd.getOptions()) {
      if (StringUtils.isNotBlank(option.getValue())) {
        config.addProperty(option.getLongOpt(), option.getValue());
      }
    }
    if (cmd.hasOption('h')) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.setWidth(120);
      formatter.printHelp(
          "java -Dlogback.configurationFile=logback.xml -jar whatIsOilPriceNow.jar [options]",
          options);
      return;
    }

    RockNRoller roller = new RockNRoller(config);
    roller.startMainLoop();
  }
コード例 #14
0
  public static void main(String args[]) throws Exception {
    Util util = new Util();
    String observationLimit;
    String dataFile;
    String processSummaryStatics;

    CommandLineParser parser = new BasicParser();
    try {
      CommandLine cmd = parser.parse(util.getOptions(), args);
      dataFile = cmd.getOptionValue("f");
      processSummaryStatics = cmd.getOptionValue("s");
      observationLimit = cmd.getOptionValue("l");
    } catch (Exception e) {
      e.printStackTrace();
      return;
    }

    if (StringUtils.isEmpty(dataFile)) {
      util.help();
    }
    // Default Values;
    Boolean summaryStats = true;
    Long obsLimit = -1l;

    Util.fileCheck(dataFile);
    summaryStats = Util.processSummaryStatisticsCheck(processSummaryStatics);
    ;
    obsLimit = Util.observationLimitCheck(observationLimit);
    ;

    GenerateDDI generateDDI = new GenerateDDI();
    generateDDI.generateDDI(dataFile, summaryStats, obsLimit);
    System.out.println("Finished. Exiting.");
  }
コード例 #15
0
ファイル: CinderApp.java プロジェクト: owendavisco/cinder
  public static void main(String[] args) throws Exception {
    Options options = new Options();

    // Add the option -kms or --kms_ws_uri followed by an argument
    // example: -kms "ws://192.168.1.119:8888/kurento"
    options.addOption(
        Option.builder("kms")
            .longOpt("kms_ws_uri")
            .hasArg()
            .desc("Changes the default kurento media server ip")
            .argName("kms")
            .build());
    CommandLineParser parser = new DefaultParser();

    // Parse the command line for defined arguments
    CommandLine line = parser.parse(options, args);

    // Set the kurento media server uri to either the parsed argument or just localhost
    KMS_WS_URI =
        line.getOptionValue("kms") != null
            ? line.getOptionValue("kms")
            : "ws://localhost:8888/kurento";

    // Create the application
    new SpringApplication(CinderApp.class).run(args);
  }
コード例 #16
0
ファイル: Docnos2Titles.java プロジェクト: AdeDZY/Ivory
  @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;
  }
コード例 #17
0
ファイル: WSNGui.java プロジェクト: ramdhany/testbed-runtime
  public static void main(String[] args) {
    String propertyFile;
    // create the command line parser
    CommandLineParser parser = new PosixParser();
    Options options = new Options();
    options.addOption(
        "f",
        "file",
        true,
        "A property file containing values to override auto-detected field values (optional)");

    CommandLine line;
    Properties properties = new Properties();
    try {

      line = parser.parse(options, args);

      if (line.hasOption('f')) {
        propertyFile = line.getOptionValue('f');
        properties.load(new FileReader(propertyFile));
      }

    } catch (Exception e) {
      log.error(e.getMessage() + "\n Start aborted!");
      System.exit(1);
    }

    WSNGui gui = new WSNGui(properties);
    gui.frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    gui.frame.setVisible(true);
  }
コード例 #18
0
    public static Options parseArgs(String cmdArgs[]) {
      CommandLineParser parser = new GnuParser();
      CmdLineOptions options = getCmdLineOptions();
      try {
        CommandLine cmd = parser.parse(options, cmdArgs, false);

        if (cmd.hasOption(HELP_OPTION)) {
          printUsage(options);
          System.exit(0);
        }

        String[] args = cmd.getArgs();
        if (args.length == 0) {
          System.err.println("No sstables to split");
          printUsage(options);
          System.exit(1);
        }
        Options opts = new Options(Arrays.asList(args));
        opts.debug = cmd.hasOption(DEBUG_OPTION);
        opts.verbose = cmd.hasOption(VERBOSE_OPTION);
        opts.snapshot = !cmd.hasOption(NO_SNAPSHOT_OPTION);
        opts.sizeInMB = DEFAULT_SSTABLE_SIZE;

        if (cmd.hasOption(SIZE_OPTION))
          opts.sizeInMB = Integer.valueOf(cmd.getOptionValue(SIZE_OPTION));

        return opts;
      } catch (ParseException e) {
        errorMsg(e.getMessage(), options);
        return null;
      }
    }
コード例 #19
0
  public static void main(String args[]) throws IOException, ParseException {
    Options options = new Options();
    options.addOption("u", "uniquehits", false, "only output hits with a single mapping");
    options.addOption(
        "s",
        "nosuboptimal",
        false,
        "do not include hits whose score is not equal to the best score for the read");
    CommandLineParser parser = new GnuParser();
    CommandLine cl = parser.parse(options, args, false);
    boolean uniqueOnly = cl.hasOption("uniquehits");
    boolean filterSubOpt = cl.hasOption("nosuboptimal");

    ArrayList<String[]> lines = new ArrayList<String[]>();

    String line;
    String lastRead = "";
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while ((line = reader.readLine()) != null) {
      String pieces[] = line.split("\t");
      if (!pieces[0].equals(lastRead)) {
        printLines(lines, uniqueOnly, filterSubOpt);
        lines.clear();
      }
      lines.add(pieces);
      lastRead = pieces[0];
    }
    printLines(lines, uniqueOnly, filterSubOpt);
  }
コード例 #20
0
  public static boolean parseArgs(String[] args) {
    CommandLineParser parser = new BasicParser();
    CommandLine cmd;
    try {
      cmd = parser.parse(options, args);

      if (cmd.hasOption("tbn") && cmd.hasOption("tbp")) {
        tbUsername = cmd.getOptionValue("tbn");
        tbPassword = cmd.getOptionValue("tbp");
      } else {
        System.out.println("Please enter your Topbot username and password");
        return false;
      }

      if (cmd.hasOption("n")) {
        numAccounts = Integer.parseInt(cmd.getOptionValue("n"));

        if (numAccounts >= 9)
          System.out.println("WARNING: The number of accounts exceeds the number of f2p worlds!");
      } else numAccounts = DEFAULT_ACCOUNT_NUM;

      if (cmd.hasOption("bp")) botPassword = cmd.getOptionValue("bp");
      else botPassword = DEFAULT_PW;

      if (cmd.hasOption("s")) script = cmd.getOptionValue("s");
      else script = DEFAULT_SCRIPT;

      return true;
    } catch (Exception e) {
      System.out.println("Couldn't parse arguments");
      return false;
    }
  }
コード例 #21
0
ファイル: SQLServerManager.java プロジェクト: mapr/sqoop
  /**
   * Parse extra arguments.
   *
   * @param args Extra arguments array
   * @throws ParseException
   */
  void parseExtraArgs(String[] args) throws ParseException {
    // No-op when no extra arguments are present
    if (args == null || args.length == 0) {
      return;
    }

    // We do not need extended abilities of SqoopParser, so we're using
    // Gnu parser instead.
    CommandLineParser parser = new GnuParser();
    CommandLine cmdLine = parser.parse(getExtraOptions(), args, true);

    // Apply extra options
    if (cmdLine.hasOption(SCHEMA)) {
      String schemaName = cmdLine.getOptionValue(SCHEMA);
      LOG.info("We will use schema " + schemaName);

      this.schema = schemaName;
    }

    // Apply table hints
    if (cmdLine.hasOption(TABLE_HINTS)) {
      String hints = cmdLine.getOptionValue(TABLE_HINTS);
      LOG.info("Sqoop will use following table hints for data transfer: " + hints);

      this.tableHints = hints;
    }

    identityInserts = cmdLine.hasOption(IDENTITY_INSERT);
  }
コード例 #22
0
ファイル: MetricsServer.java プロジェクト: bigloupe/bigloupe
  /**
   * Parse arguments
   *
   * @param args
   */
  private void commandLineParser(String[] args) throws ParseException {
    options = new Options();
    options.addOption("help", false, "print this message");
    options.addOption(
        OPTION_CARBON_PORT,
        true,
        "specify port for graphite/carbon events - (" + DEFAULT_PORT_CARBON + " by default)");
    options.addOption(
        OPTION_STATSD_PORT,
        true,
        "specify port for statsD events - (" + DEFAULT_PORT_STATSD + " by default)");
    options.addOption(
        OPTION_WEBSERVER_PORT,
        true,
        "specify port for http server - (" + DEFAULT_PORT_WEBSERVER + " by default)");
    options.addOption(
        OPTION_CARBON_ONLY, false, "start TCP socket only for graphite/carbon events");
    options.addOption(OPTION_STATSD_ONLY, false, "start UDP socket only for statsd events");
    options.addOption(OPTION_NO_WEBSERVER, false, "don't start webserver");
    options.addOption(OPTION_HAWTIO, false, "start hawtio in webserver");

    options.addOption(OPTION_BACKEND, true, "backend implementation available : " + getBackends());
    options.addOption(OPTION_WEBSERVER_WEBROOT, true, "HTTP base resource (must be a path)");

    CommandLineParser parser = new PosixParser();
    cmd = parser.parse(options, args);

    if (cmd.hasOption("help")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("java -jar bigloupe-chart.jar [options]", options);
      System.exit(0);
    }
  }
コード例 #23
0
  @Test
  public void testDynamicProperties() throws IOException {

    Map<String, String> map = new HashMap<String, String>(System.getenv());
    File tmpFolder = tmp.newFolder();
    File fakeConf = new File(tmpFolder, "flink-conf.yaml");
    fakeConf.createNewFile();
    map.put(ConfigConstants.ENV_FLINK_CONF_DIR, tmpFolder.getAbsolutePath());
    TestBaseUtils.setEnv(map);
    FlinkYarnSessionCli cli = new FlinkYarnSessionCli("", "", false);
    Options options = new Options();
    cli.addGeneralOptions(options);
    cli.addRunOptions(options);

    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = null;
    try {
      cmd =
          parser.parse(
              options,
              new String[] {"run", "-j", "fake.jar", "-n", "15", "-D", "akka.ask.timeout=5 min"});
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail("Parsing failed with " + e.getMessage());
    }

    AbstractYarnClusterDescriptor flinkYarnDescriptor = cli.createDescriptor(null, cmd);

    Assert.assertNotNull(flinkYarnDescriptor);

    Map<String, String> dynProperties =
        FlinkYarnSessionCli.getDynamicProperties(flinkYarnDescriptor.getDynamicPropertiesEncoded());
    Assert.assertEquals(1, dynProperties.size());
    Assert.assertEquals("5 min", dynProperties.get("akka.ask.timeout"));
  }
コード例 #24
0
  /**
   * Creates a parser for command line parsing.
   *
   * @param args
   * @throws ParseException
   */
  private void retrieveParser(String[] args) throws ParseException {
    // Creates parser.
    CommandLineParser parser = new BasicParser();

    // Execute the parsing.
    commandLine = parser.parse(options, args);
  }
コード例 #25
0
ファイル: Main.java プロジェクト: jbartram/liquibase
  public void init(String[] args) throws UserError {
    Context.reset();
    CommandLineParser globalParser = new GnuParser();

    List<String> globalArgs = new ArrayList<String>();

    boolean inGlobal = true;
    for (String arg : args) {
      if (inGlobal) {
        if (arg.startsWith("--")) {
          globalArgs.add(arg);
        } else {
          this.command = arg;
          inGlobal = false;
        }
      } else {
        commandArgs.add(arg);
      }
    }

    try {
      this.globalArguments =
          globalParser.parse(globalOptions, globalArgs.toArray(new String[globalArgs.size()]));
    } catch (ParseException e) {
      throw new UserError("Error parsing global command line argument: " + e.getMessage());
    }
  }
コード例 #26
0
 /** Check command line arguments. */
 public void checkComanLineArgs() {
   options.addOption(COMMANDS_MANAGER_U, COMMANDS_MANAGER_USER, true, USER_DESCRIPTION);
   options.addOption(COMMANDS_MANAGER_P, COMMANDS_MANAGER_PASSWORD, true, PASSWORD_DESCRIPTION);
   options.addOption(
       COMMANDS_MANAGER_FETCH_F, COMMANDS_MANAGER_FETCH_FILE, false, FETCH_FILE_DESCRIPTION);
   options.addOption(COMMANDS_MANAGER_H, COMMANDS_MANAGER_HELP, false, HELP_DESCRIPTION);
   CommandLineParser parser = new PosixParser();
   CommandLine cmd;
   try {
     cmd = parser.parse(options, args);
     if (cmd.hasOption(COMMANDS_MANAGER_U) && cmd.hasOption(COMMANDS_MANAGER_P)
         || cmd.hasOption(COMMANDS_MANAGER_USER) && cmd.hasOption(COMMANDS_MANAGER_PASSWORD)) {
       setName(cmd.getOptionValue(COMMANDS_MANAGER_U));
       setPass(cmd.getOptionValue(COMMANDS_MANAGER_P));
     } else if (cmd.hasOption(COMMANDS_MANAGER_FETCH_F)) {
       isGetLink = false;
     } else if (cmd.hasOption(COMMANDS_MANAGER_H)) {
       HelpFormatter formatter = new HelpFormatter();
       formatter.printHelp(COMMANDS_MANAGER_H, options);
       System.exit(0);
     }
   } catch (ParseException e) {
     // e.printStackTrace();
     LOGGER.error(e);
   }
 }
コード例 #27
0
ファイル: Parameters.java プロジェクト: tompecina/bitwriter
  /**
   * Parse the command line.
   *
   * @param args command-line arguments
   * @return line parsed command line
   * @exception ParametersException on error in parameters
   */
  public CommandLine parse(final String args[]) throws ParametersException {
    log.fine("Command line parsing started");

    final CommandLineParser parser = new DefaultParser();
    CommandLine line;
    try {
      line = parser.parse(options, args);
    } catch (final ParseException exception) {
      throw new ParametersException(
          "Failed to parse the command line, exception: " + exception.getMessage());
    }

    fileNames = line.getArgs();

    outputFileNameFlag = line.hasOption("o");
    if (outputFileNameFlag) {
      outputFileName = line.getOptionValue("o");
    }

    crcFileNameFlag = line.hasOption("c");
    if (crcFileNameFlag) {
      crcFileName = line.getOptionValue("c");
    }

    if (line.hasOption("s")) {
      literalStrings = line.getOptionValues("s");
    }

    listCrcFlag = line.hasOption("l");

    hexMode = line.hasOption("x");

    log.fine("Command line parsing completed");
    return line;
  }
コード例 #28
0
ファイル: Main.java プロジェクト: pcgomes/javaparser2jctree
  private static boolean setOptions(String[] lcommand) {

    Options loptions = new Options();
    loptions.addOption(new Option("d", "debug", false, "print debug information (highly verbose)"));
    loptions.addOption(new Option("o", "stdout", false, "print output files to standard output"));
    loptions.addOption(new Option("w", "warning", false, "print warning messages"));

    CommandLineParser clparser = new PosixParser();
    try {
      cmd = clparser.parse(loptions, lcommand);
    } catch (org.apache.commons.cli.ParseException e) {
      String mytoolcmd = "java -jar stave.jar";
      String myoptlist = " <options> <source files>";
      String myheader = "Convert JavaParser's AST to OpenJDK's AST";
      String myfooter = "More info: https://github.com/pcgomes/javaparser2jctree";

      HelpFormatter formatter = new HelpFormatter();
      // formatter.printUsage( new PrintWriter(System.out,true), 100, "java -jar synctask.jar",
      // loptions );
      // formatter.printHelp( mytoolcmd + myoptlist, myheader, loptions, myfooter, false);
      formatter.printHelp(mytoolcmd + myoptlist, loptions, false);
      return (false);
    }

    return (true);
  }
コード例 #29
0
ファイル: DocSimStatMain.java プロジェクト: dvelle/docsim
  public static void main(String[] args) throws Exception {
    Options options = new Options();
    options.addOption("i", "input-file", true, "input data file.");
    options.addOption("o", "output-file", true, "output file.");
    options.addOption("h", "help", false, "display help document");
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);
    String inputFile = null;
    String outputFile = null;
    if (cmd.hasOption("i")) {
      inputFile = cmd.getOptionValue("i");
    }
    if (cmd.hasOption("o")) {
      outputFile = cmd.getOptionValue("o");
    }
    boolean help = false;
    if (inputFile == null || outputFile == null) {
      help = true;
    }
    if (cmd.hasOption("h") || help) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("docsim stat", options);
      return;
    }
    // DocSimStatTest test = new DocSimStatTest("");
    // test.notestSummary();

    DocSimLatticeStatistics stat = BasicStatisticsFormatter.getStatFromFile(inputFile);
    BasicStatisticsFormatter.avgCalcBySize2File(stat, outputFile);
  }
コード例 #30
0
ファイル: Main.java プロジェクト: BlackCodeZone/ImageMatcher
  @SuppressWarnings("deprecation")
  public static void main(String[] args) throws ParseException {
    // TODO Auto-generated method stub

    // Create a Parser
    String sourceImage = null;
    String subImage = null;
    CommandLine commandLine = null;
    CommandLineParser parser = new BasicParser();
    Options options = new Options();
    options.addOption("h", "help", false, "help message");
    options.addOption("s", "source", true, "source image");
    options.addOption("t", "template", true, "sub image");
    // Parse the program arguments
    try {
      commandLine = parser.parse(options, args);
    } catch (Exception e) {
      // TODO: handle exception
      printUsage();
    }

    // Set the appropriate variables based on supplied options
    if (commandLine.hasOption('h')) {
      printUsage();
      System.exit(0);
    }
    if (commandLine.hasOption('s')) {
      sourceImage = commandLine.getOptionValue('s');
    }
    if (commandLine.hasOption('t')) {
      subImage = commandLine.getOptionValue('t');
    }

    verifyImage(sourceImage, subImage);
  }