예제 #1
0
  public WakeOnLan(JSAPResult cmdConfig) throws JSAPException, IOException {
    super();

    if (!cmdConfig.success()) {
      printHelpAndExit();
    }

    if (cmdConfig.getBoolean(CMD_HELP)) {
      printHelpAndExit();
    }

    if (cmdConfig.getBoolean(CMD_VERSION)) {
      printVersionAndExit();
    }

    String[] machines = cmdConfig.getStringArray(CMD_ADDRESSES);
    String configPath = cmdConfig.getString(CMD_CONFIG_FILE);
    Configuration config = new Configuration(configPath);

    if (null == machines || 0 == machines.length) {
      showGUI(config);
    } else {
      InetAddress host = cmdConfig.getInetAddress(CMD_INET_ADDRESS);
      int port = cmdConfig.getInt(CMD_PORT);

      wakeup(machines, config, host, port);
    }
  }
예제 #2
0
  protected JSAPResult parseParameters(String[] args) throws Exception {
    jsap = buildCommandLineOptions();

    JSAPResult config = jsap.parse(args);
    if (!config.success() || jsap.messagePrinted()) {
      Iterator<?> messageIterator = config.getErrorMessageIterator();
      while (messageIterator.hasNext()) System.err.println(messageIterator.next());
      System.err.println(jsap.getHelp());
      System.exit(1);
    }

    return config;
  }
예제 #3
0
  public static void execCommandArgs(String[] args) {
    JSAP jsap = new JSAP();
    final String update = "up";
    final String help = "help";
    final String prozess = "tex";
    final String outout = "out";
    final String src = "src";

    try {

      Switch swHelp = new Switch(help);
      swHelp.setShortFlag('h');
      swHelp.setLongFlag("help");
      swHelp.setHelp("Show this.");

      jsap.registerParameter(swHelp);

      Switch swUpdate = new Switch(update);
      swUpdate.setShortFlag('u');
      swUpdate.setLongFlag("update");
      swUpdate.setHelp("Updates from Remote");

      jsap.registerParameter(swUpdate);

      Switch swTex = new Switch(prozess);
      swTex.setShortFlag('t');
      swTex.setLongFlag("transform");
      swTex.setHelp("starts transform to tex");

      jsap.registerParameter(swTex);

      FlaggedOption optOut = new FlaggedOption(outout);
      optOut.setStringParser(JSAP.STRING_PARSER);
      optOut.setDefault(DEFAULT_OUTPUT_FOLDER + "/Songbook.tex");
      optOut.setRequired(false);
      optOut.setShortFlag('o');
      optOut.setLongFlag("output");
      optOut.setHelp("Filename for output");

      jsap.registerParameter(optOut);

      FlaggedOption optSrc = new FlaggedOption(src);
      optSrc.setStringParser(JSAP.STRING_PARSER);
      optSrc.setDefault(DEFAULT_DATA_FOLDER);
      optSrc.setRequired(false);
      optSrc.setShortFlag('s');
      optSrc.setLongFlag("src");
      optSrc.setHelp("input folder");

      jsap.registerParameter(optSrc);

      if (false) {
        final String style = "style";
        FlaggedOption optStyle = new FlaggedOption(style);
        optStyle.setStringParser(JSAP.STRING_PARSER);
        optStyle.setDefault(getDefault());
        optStyle.setRequired(false);
        optStyle.setShortFlag('y');
        optStyle.setLongFlag("style");

        jsap.registerParameter(optStyle);
      }

    } catch (JSAPException e) {
      throw new IllegalStateException(e);
    }
    JSAPResult config = jsap.parse(args);
    if (config.getBoolean("help") || !config.success() || !config.getBoolean(prozess)) {
      // TODO jar name/ package
      System.out.println("Usage: java -jar " + "??????.jar " + jsap.getUsage());

      System.out.println();
      System.out.println(jsap.getHelp());
      System.out.println();
    }

    if (config.getBoolean(update)) {
      updater.update();
    }
    if (config.getBoolean(prozess)) {
      File sourceDir = new File(config.getString(src));
      if (!sourceDir.isDirectory()) {
        System.out.println("No songs. Please update; " + sourceDir.getAbsolutePath());
      } else {
        processSongs(config.getString(src), config.getString(outout));
      }
    }
  }
예제 #4
0
  public static void main(String[] args) throws JSAPException, IOException, RatingException {
    CommandLineInterface commandLineInterface = new CommandLineInterface();

    JSAPResult jsap = commandLineInterface.parse(args);
    if (!jsap.success()) {
      throw new JSAPException("Command line parsing failed.");
    }

    //////////////////////////////////////////////////////
    //             now configure everything             //
    //////////////////////////////////////////////////////
    Configuration configuration = new Configuration();

    /* configure debug level */
    String debugLevel = jsap.getString(OPTION_DEBUG_LEVEL).toUpperCase();
    Level level = Level.parse(debugLevel);
    configuration.setDebugLevel(level);

    /* configure input dir */
    MatchSetReader matchSetReader =
        new FileMatchSetReader(jsap.getFile(OPTION_INPUT_DIR), configuration);
    configuration.setMatchReader(matchSetReader);

    /* configure output dir */
    Configuration.setOutputDir(jsap.getFile(OPTION_OUTPUT_DIR));

    /* configure previous ratings file */
    configuration.setPreviousRatings(jsap.getFile(OPTION_PREVIOUS_RATINGS));

    /* configure rating algorithms */
    if (jsap.contains(OPTION_DYNAMIC_LINEAR_REGRESSION)) {
      int maxMatchSets = jsap.getInt(OPTION_DYNAMIC_LINEAR_REGRESSION);
      configuration.addRatingSystem(new DynamicLinearRegressionStrategy(maxMatchSets));
    }
    if (jsap.contains(OPTION_CONSTANT_LINEAR_REGRESSION)) {
      double learningRate = jsap.getDouble(OPTION_CONSTANT_LINEAR_REGRESSION);
      configuration.addRatingSystem(new ConstantLinearRegressionStrategy(learningRate));
    }
    if (jsap.getBoolean(OPTION_DIRECT_SCORES)) {
      configuration.addRatingSystem(new DirectScoresStrategy());
    }
    /* ****************** ADD NEW RATING SYSTEMS HERE ****************** */

    /* make ignore list */
    Set<Player> ignorePlayers =
        new IgnorePlayerSet(jsap.getFile(OPTION_INPUT_DIR), configuration.getPlayerSet());

    /* configure output methods */
    for (RatingSystemType type : configuration.getEnabledRatingSystems()) {
      if (jsap.getBoolean(OPTION_CSV_OUTPUT)) {
        configuration.addCSVOutputBuilder(type, ignorePlayers);
      }
      if (jsap.getBoolean(OPTION_GNUPLOT_OUTPUT)) {
        configuration.addGnuplotOutputBuilder(type, ignorePlayers);
      }
      if (jsap.getBoolean(OPTION_HTML_OUTPUT)) {
        configuration.addHtmlOutputBuilder(type, ignorePlayers);
      }
      /* ****************** ADD NEW OUTPUT METHODS HERE ****************** */
    }

    configuration.run();
  }