Examples of CommandLine


Examples of org.apache.commons.cli.CommandLine

    options.addOption(keyOption);

    CommandLineParser argsParser = new PosixParser();

    try {
      CommandLine commandLine = argsParser.parse(options, args);

      if (commandLine.hasOption(helpOption.getOpt())) {
        printUsage(options);
        System.exit(0);
      }

      String serverURL = commandLine.getOptionValue(serverURLOption.getOpt());
      String[] otherArgs = commandLine.getArgs();

      if (serverURL == null || otherArgs.length > 1) {
        System.out.println("Please specify a server URL");
        printUsage(options);
        System.exit(2);
      }

      if (!serverURL.endsWith("/")) {
        serverURL += "/";
      }
      serverURL += SesameServer.SHUTDOWN_PATH;

      String keyString = commandLine.getOptionValue(keyOption.getOpt());

      try {
        URL url = new URL(serverURL);

        System.out.println("connecting to the server...");
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

    options.addOptionGroup(connectGroup);

    CommandLineParser argsParser = new PosixParser();

    try {
      CommandLine commandLine = argsParser.parse(options, args);

      if (commandLine.hasOption(helpOption.getOpt())) {
        printUsage(options);
        System.exit(0);
      }

      if (commandLine.hasOption(versionOption.getOpt())) {
        System.out.println(VERSION);
        System.exit(0);
      }

      String dir = commandLine.getOptionValue(dirOption.getOpt());
      String serverURL = commandLine.getOptionValue(serverURLOption.getOpt());
      String[] otherArgs = commandLine.getArgs();

      if (otherArgs.length > 1) {
        printUsage(options);
        System.exit(1);
      }
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

  {
    Options options = createCliOptions();
    CommandLineParser argsParser = new PosixParser();

    try {
      CommandLine commandLine = argsParser.parse(options, args);

      if (commandLine.hasOption(helpOption.getOpt())) {
        printUsage(options);
      }
      else if (commandLine.hasOption(versionOption.getOpt())) {
        printVersion();
      }
      else {
        startServer(options, commandLine);
      }
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

    public static void main(String[] args)
    {
        Schema2XMI schema2Xmi = new Schema2XMI();
        try
        {
            CommandLine commandLine = schema2Xmi.parseCommands(args);
            if (
                commandLine.hasOption(HELP) ||
                !(
                    commandLine.hasOption(OUTPUT_MODEL) && commandLine.hasOption(DRIVER) &&
                    commandLine.hasOption(CONNECTION_URL) && commandLine.hasOption(USER) &&
                    commandLine.hasOption(PASSWORD)
                ))
            {
                Schema2XMI.displayHelp();
            }
            else
            {
                String inputModel = commandLine.getOptionValue(INPUT_MODEL);
                SchemaTransformer transformer =
                    new SchemaTransformer(
                        commandLine.getOptionValue(DRIVER),
                        commandLine.getOptionValue(CONNECTION_URL),
                        commandLine.getOptionValue(USER),
                        commandLine.getOptionValue(PASSWORD));

                // set the extra options
                transformer.setXmiVersion(commandLine.getOptionValue(XMI_VERSION));
                transformer.setTypeMappings(commandLine.getOptionValue(MAPPINGS));
                transformer.setPackageName(commandLine.getOptionValue(PACKAGE));
                transformer.setSchema(commandLine.getOptionValue(SCHEMA));
                transformer.setTableNamePattern(commandLine.getOptionValue(TABLE_PATTERN));
                transformer.setColumnNamePattern(commandLine.getOptionValue(COLUMN_PATTERN));
                transformer.setClassStereotypes(commandLine.getOptionValue(CLASS_STEREOTYPES));
                transformer.setIdentifierStereotypes(commandLine.getOptionValue(IDENTIFIER_STEREOTYPES));
                transformer.setTableTaggedValue(commandLine.getOptionValue(TABLE_TAGGEDVALUE));
                transformer.setColumnTaggedValue(commandLine.getOptionValue(COLUMN_TAGGEDVALUE));

                String outputLocation = commandLine.getOptionValue(OUTPUT_MODEL);
                transformer.transform(inputModel, outputLocation);
            }
        }
        catch (Throwable throwable)
        {
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

    // TODO: should we have an 'err' printstream too for ParseException?
    static void processArgs(String[] args, final PrintStream out) {
        Options options = buildOptions();

        try {
            CommandLine cmd = parseCommandLine(options, args);

            if (cmd.hasOption('h')) {
                printHelp(out, options);
            } else if (cmd.hasOption('v')) {
                String version = GroovySystem.getVersion();
                out.println("Groovy Version: " + version + " JVM: " + System.getProperty("java.version"));
            } else {
                // If we fail, then exit with an error so scripting frameworks can catch it
                // TODO: pass printstream(s) down through process
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

                    try {
                        Options options = FileSystemCompiler.createCompilationOptions();

                        PosixParser cliParser = new PosixParser();

                        CommandLine cli;
                        cli = cliParser.parse(options, commandLine);

                        configuration = FileSystemCompiler.generateCompilerConfigurationFromOptions(cli);
                        configuration.setScriptExtensions(getScriptExtensions());
                        String tmpExtension = getScriptExtension();
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

    options.addOption(new Option(IN_OPT, IN_OPT_LONG, true, "Input file"));

    options.addOption(new Option(OUT_OPT, OUT_OPT_LONG, true, "Output file"));

    CommandLine line = null;
    try
    {
      line = new PosixParser().parse(options, args);
    }
    catch (ParseException pe)
    {
      System.err.println(pe.getMessage());
      return;
    }

    if (!line.hasOption(LEXICON_OPT))
    {
      System.err.println("Lexicon is not specified");
      return;
    }

    if (!line.hasOption(GRAMMAR_OPT))
    {
      System.err.println("Grammar is not specified");
      return;
    }

    if (!line.hasOption(IN_OPT))
    {
      System.err.println("Input file is not specified");
      return;
    }

    if (!line.hasOption(OUT_OPT))
    {
      System.err.println("Output file is not specified");
      return;
    }

    Main main = new Main();
    main.setLexicon(new File(line.getOptionValue(LEXICON_OPT)));
    main.setGrammar(new File(line.getOptionValue(GRAMMAR_OPT)));

    try
    {
      main.process(new File(line.getOptionValue(IN_OPT)), new File(line.getOptionValue(OUT_OPT)));
    }
    catch (Exception e)
    {
      System.err.println(e.getMessage());
    }
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

      options.addOption(optTargetFile);
      options.addOption(optLogLevel);
      options.addOption(optChangeUser);
     
      CommandLineParser parser = new GnuParser();
      CommandLine line=null;
      try{
        line = parser.parse(options, args);
      } catch(Exception e){
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("cronconverter", options, true);
        System.exit(0);
      }
     
      sourceFile = getWholeArgument(line.getOptionValues("crontab"));
      if (sourceFile.equalsIgnoreCase("/etc/crontab")) sysTab = true;
      targetFile = getWholeArgument(line.getOptionValues("target"));
     
      String ll = line.getOptionValue("v", ""+SOSStandardLogger.INFO);
      logLevel = Integer.parseInt(ll);
      if (line.hasOption(optSysTab.getOpt())){
        sysTab =(line.getOptionValue(optSysTab.getOpt()).trim().equals("1"));
      }   
      useOldRunTime = line.hasOption("oldRunTime");
      changeUser = "";
      if (line.hasOption("changeuser")){
        changeUser = getWholeArgument(line.getOptionValues("changeuser"));
      }     
           
      jobTimeout = line.getOptionValue("timeout");
      if (logLevel==0) logLevel=SOSLogger.INFO;
      sosLogger = new SOSStandardLogger(logLevel);     
           
      target = new File(targetFile);
      source = new File(sourceFile);
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

    options.addOption("p", "port", true, "Port to bind to [default: 8080]");
    options.addOption("ro", "readonly", false, "Respond only to GET HTTP " +
      "method requests [default: false]");
    options.addOption(null, "infoport", true, "Port for web UI");

    CommandLine commandLine = null;
    try {
      commandLine = new PosixParser().parse(options, args);
    } catch (ParseException e) {
      LOG.error("Could not parse: ", e);
      printUsageAndExit(options, -1);
    }

    // check for user-defined port setting, if so override the conf
    if (commandLine != null && commandLine.hasOption("port")) {
      String val = commandLine.getOptionValue("port");
      servlet.getConfiguration()
          .setInt("hbase.rest.port", Integer.valueOf(val));
      LOG.debug("port set to " + val);
    }

    // check if server should only process GET requests, if so override the conf
    if (commandLine != null && commandLine.hasOption("readonly")) {
      servlet.getConfiguration().setBoolean("hbase.rest.readonly", true);
      LOG.debug("readonly set to true");
    }

    // check for user-defined info server port setting, if so override the conf
    if (commandLine != null && commandLine.hasOption("infoport")) {
      String val = commandLine.getOptionValue("infoport");
      servlet.getConfiguration()
          .setInt("hbase.rest.info.port", Integer.valueOf(val));
      LOG.debug("Web UI port set to " + val);
    }

    @SuppressWarnings("unchecked")
    List<String> remainingArgs = commandLine != null ?
        commandLine.getArgList() : new ArrayList<String>();
    if (remainingArgs.size() != 1) {
      printUsageAndExit(options, 1);
    }

    String command = remainingArgs.get(0);
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

        ImplType.THREAD_POOL.simpleClassName());

    options.addOptionGroup(ImplType.createOptionGroup());

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

    // This is so complicated to please both bin/hbase and bin/hbase-daemon.
    // hbase-daemon provides "start" and "stop" arguments
    // hbase should print the help if no argument is provided
    List<String> commandLine = Arrays.asList(args);
    boolean stop = commandLine.contains("stop");
    boolean start = commandLine.contains("start");
    boolean invalidStartStop = (start && stop) || (!start && !stop);
    if (cmd.hasOption("help") || invalidStartStop) {
      if (invalidStartStop) {
        LOG.error("Exactly one of 'start' and 'stop' has to be specified");
      }
      printUsageAndExit(options, 1);
    }

    // Get port to bind to
    try {
      int listenPort = Integer.parseInt(cmd.getOptionValue(PORT_OPTION,
          String.valueOf(DEFAULT_LISTEN_PORT)));
      conf.setInt(ThriftServerRunner.PORT_CONF_KEY, listenPort);
    } catch (NumberFormatException e) {
      LOG.error("Could not parse the value provided for the port option", e);
      printUsageAndExit(options, -1);
    }

    // check for user-defined info server port setting, if so override the conf
    try {
      if (cmd.hasOption("infoport")) {
        String val = cmd.getOptionValue("infoport");
        conf.setInt("hbase.thrift.info.port", Integer.valueOf(val));
        LOG.debug("Web UI port set to " + val);
      }
    } catch (NumberFormatException e) {
      LOG.error("Could not parse the value provided for the infoport option", e);
      printUsageAndExit(options, -1);
    }

    // Make optional changes to the configuration based on command-line options
    optionToConf(cmd, MIN_WORKERS_OPTION,
        conf, TBoundedThreadPoolServer.MIN_WORKER_THREADS_CONF_KEY);
    optionToConf(cmd, MAX_WORKERS_OPTION,
        conf, TBoundedThreadPoolServer.MAX_WORKER_THREADS_CONF_KEY);
    optionToConf(cmd, MAX_QUEUE_SIZE_OPTION,
        conf, TBoundedThreadPoolServer.MAX_QUEUED_REQUESTS_CONF_KEY);
    optionToConf(cmd, KEEP_ALIVE_SEC_OPTION,
        conf, TBoundedThreadPoolServer.THREAD_KEEP_ALIVE_TIME_SEC_CONF_KEY);

    // Set general thrift server options
    conf.setBoolean(
        ThriftServerRunner.COMPACT_CONF_KEY, cmd.hasOption(COMPACT_OPTION));
    conf.setBoolean(
        ThriftServerRunner.FRAMED_CONF_KEY, cmd.hasOption(FRAMED_OPTION));
    if (cmd.hasOption(BIND_OPTION)) {
      conf.set(
          ThriftServerRunner.BIND_CONF_KEY, cmd.getOptionValue(BIND_OPTION));
    }

    ImplType.setServerImpl(cmd, conf);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.