/** 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"));
  }
Beispiel #2
0
  /**
   * 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);
    }
  }
Beispiel #3
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;
  }
Beispiel #4
0
 private static Options options() {
   Options options = new Options();
   options.addOption(SYS_CONFIG_OPTION);
   options.addOption(JOB_CONFIG_OPTION);
   options.addOption(HELP_OPTION);
   return options;
 }
 public Scanner() {
   options = new Options();
   options.addOption("i", true, "Path to Minecraft mod .jar");
   options.addOption("l", true, "Path to Minecraft install directory");
   parser = new DefaultParser();
   executor = Executors.newCachedThreadPool();
 }
Beispiel #6
0
  @Override
  public int run(String[] args) throws Exception {

    Options options = new Options();
    options.addOption("c", "concurrent", false, "run concurrently with generation");

    GnuParser parser = new GnuParser();
    CommandLine cmd = null;
    try {
      cmd = parser.parse(options, args);
      if (cmd.getArgs().length != 4) {
        throw new ParseException(
            "Did not see expected # of arguments, saw " + cmd.getArgs().length);
      }
    } catch (ParseException e) {
      System.err.println("Failed to parse command line " + e.getMessage());
      System.err.println();
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp(getClass().getSimpleName() + " <output dir> <num reducers>", options);
      System.exit(-1);
    }

    String outputDir = cmd.getArgs()[0];
    int numReducers = Integer.parseInt(cmd.getArgs()[1]);
    String accessKey = cmd.getArgs()[2];
    String secretKey = cmd.getArgs()[3];

    return run(outputDir, numReducers, cmd.hasOption("c"), accessKey, secretKey);
  }
Beispiel #7
0
  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);
    }
  }
  @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;
  }
Beispiel #9
0
  @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);
  }
Beispiel #10
0
  /**
   * @param args commandline arguments
   * @throws ParseException if parser error
   * @throws SAXException if XML parse error
   * @throws IOException if IO error
   * @throws SQLException if database error
   * @throws RegistryExportException if export error
   */
  public static void main(String[] args)
      throws ParseException, SQLException, IOException, SAXException, RegistryExportException {
    // create an options object and populate it
    CommandLineParser parser = new PosixParser();
    Options options = new Options();
    options.addOption("f", "file", true, "output xml file for registry");
    options.addOption("s", "schema", true, "the name of the schema to export");
    CommandLine line = parser.parse(options, args);

    String file = null;
    String schema = null;

    if (line.hasOption('f')) {
      file = line.getOptionValue('f');
    } else {
      usage();
      System.exit(0);
    }

    if (line.hasOption('s')) {
      schema = line.getOptionValue('s');
    }

    saveRegistry(file, schema);
  }
    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 >= 4 || args.length < 2) {
          String msg = args.length < 2 ? "Missing arguments" : "Too many arguments";
          errorMsg(msg, options);
          System.exit(1);
        }

        String keyspace = args[0];
        String cf = args[1];
        String snapshot = null;
        if (args.length == 3) snapshot = args[2];

        Options opts = new Options(keyspace, cf, snapshot);

        opts.debug = cmd.hasOption(DEBUG_OPTION);
        opts.keepSource = cmd.hasOption(KEEP_SOURCE);

        return opts;
      } catch (ParseException e) {
        errorMsg(e.getMessage(), options);
        return null;
      }
    }
  @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();
  }
    /** Set up the command line options. */
    protected void setupOptions(Options opts) {
      // boolean options
      opts.addOption("a", "verify", false, "verify generated signatures>");

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

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

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

      OptionBuilder.hasArg();
      OptionBuilder.withArgName("outfile");
      OptionBuilder.withDescription("file the signed rrset is written to.");
      opts.addOption(OptionBuilder.create('f'));
    }
 /** 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);
   }
 }
Beispiel #15
0
  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);
  }
Beispiel #16
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);
  }
  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) {
    }
  }
Beispiel #18
0
  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();
    }
  }
  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;
    }
  }
Beispiel #20
0
  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;
  }
Beispiel #21
0
  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();
  }
Beispiel #22
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);
  }
  @Produces
  @ApplicationScoped
  public Options commandLineInterfaceOptions() {
    Options options = new Options();

    options.addOption(
        builder()
            .longOpt("download-dataset")
            .desc("This option will download the dataset from internet")
            .build());

    options.addOption(
        builder().longOpt("dataset-dir").desc("Set the dataset directory path").build());

    options.addOption(builder().longOpt("help").desc("Print this message").build());

    experiments.forEach(
        experiment -> {
          Experiment annotation = experiment.getClass().getAnnotation(Experiment.class);

          options.addOption(
              builder()
                  .longOpt(annotation.name() + "-experiment")
                  .desc(annotation.description())
                  .build());
        });

    return options;
  }
  private void processArgs(String[] args)
      throws MalformedURLException, JAXBException, IOException, URISyntaxException, Exception {
    // NOTE: Add custom cli options here.
    // cli.getOptions().addOption(option);

    // add options for logging
    Options options = cli.getOptions();
    options.addOption("proc_name", true, "process name");
    options.addOption("subproc", true, "subprocess name");
    options.addOption("env", true, "environment enumeration");

    cli.parse(args);
    CommandLine cmd = cli.getCmd();

    String procName = cmd.getOptionValue("proc_name", "TaxiiClientBA");
    String subProc = cmd.getOptionValue("subproc", "Fulfillment");
    Environment env = Environment.valueOf(cmd.getOptionValue("env", "Other"));
    // use built-in UUID generator for the session ID
    String sessionID = MessageHelper.generateMessageId();

    CFMLogFields.setBaseProcName(procName);
    CFMLogFields logger = new CFMLogFields(subProc, sessionID, env, State.PROCESSING);

    taxiiClient = generateClient(cmd);

    // Prepare the message to send.
    CollectionInformationRequest request =
        factory.createCollectionInformationRequest().withMessageId(sessionID);

    doCall(cmd, request, logger);
  }
Beispiel #25
0
  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);
  }
Beispiel #26
0
  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);
  }
Beispiel #27
0
  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);
  }
Beispiel #28
0
  public static void main(String[] argv) throws Exception {
    Options options = new Options();
    options.addOption("js", false, "Create f5less.js");
    options.addOption("p", "port", true, "ws:reload websocket server port");
    options.addOption("h", "host", true, "ws:reload websocket server host");
    options.addOption("d", "debounce", true, "debouncing for commands");

    CommandLine cmdLine = new PosixParser().parse(options, argv);
    String[] args = cmdLine.getArgs();

    if (cmdLine.hasOption("js")) {
      Files.copy(
          TheBuilder.class.getClassLoader().getResourceAsStream("f5less.js"),
          Paths.get("./f5less.js"),
          StandardCopyOption.REPLACE_EXISTING);
      System.out.println(
          "\n  f5less.js created...\n  put the following\n"
              + "     <script type=\"text/javascript\" src=\"f5less.js\"></script>\n"
              + "     <script type=\"text/javascript\">f5less.connect()</script>\n"
              + "  in the page for which you want automatic reloading (assuming 'f5less.js' is in the same directory)\n");
    }

    if (args.length < 2) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("f5less [options] path1 cmd1 path2 cmd2 ...", options);
      System.exit(-1);
    }

    final List<String> reloadPaths = new LinkedList<String>();
    final int commandsDebounce = Integer.parseInt(cmdLine.getOptionValue("d", "100"));

    for (int i = 0; i < args.length / 2; i++) {
      final String path = args[i * 2];
      final String rawCmd = args[i * 2 + 1];

      if (rawCmd.equals("ws:reload")) reloadPaths.add(path);
      else Watcher.register(path, new CommandListener(path, rawCmd, commandsDebounce));
    }

    ReloadServer reloadServer = null;
    if (!reloadPaths.isEmpty()) {
      reloadServer =
          new ReloadServer(
              cmdLine.getOptionValue("h", "localhost"),
              Integer.parseInt(cmdLine.getOptionValue("p", "9999")),
              commandsDebounce + 50);
      reloadServer.monitor(reloadPaths);
    }

    System.out.println("Press enter to exit...");
    System.in.read();

    if (reloadServer != null) reloadServer.stop();

    Watcher.stop();
    CommandListener.stop();

    System.out.println("Bye bye");
  }
Beispiel #29
0
 /** Add the commandline options common to any command */
 static {
   options.addOption("h", "help", false, "print this message");
   options.addOption("p", "project", true, "project name");
   options.addOption("a", "action", true, "action to run {create | remove}");
   options.addOption("v", "verbose", false, "verbose messages");
   options.addOption("G", "cygwin", false, "for create, indicate that the node is using cygwin");
   // options.addOption("N", "nodeslist", true, "Path to arbitrary nodes.properties file");
 }
 private static Options generateCLOptions() {
   Options options = new Options();
   // options = optionsUsingIndividualAgruments(options);
   options.addOption(optionsUsingManifest());
   // options.addOption(openNiArguments());
   options.addOption("h", "help", false, "\nPrint these helpful hints");
   return options;
 }