Package org.apache.commons.cli

Examples of org.apache.commons.cli.CommandLine


      int i = 0;
      for (Iterator iter = arguments.iterator(); iter.hasNext();) {
        String arg = (String) iter.next();
        args[i++] = arg;
      }
      CommandLine line = parser.parse(getOptions(), args);
      execute( commandName, console, line );
    } catch (ParseException e)
    {
      console.out.println(">> Invalid arguments: " + e.getMessage());     
//      printHelp(commandName, console.out);
View Full Code Here


    OptionBuilder.withDescription("Run <uis>. ',' separated list of user interfaces to run. The first one given will respond to requests without determinable source UI (e.g. further torrents added via command line).");
    OptionBuilder.withArgName("uis");
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create('u'));
   
    CommandLine commands = null;
    try {
      commands = parser.parse(options, args, true);
    } catch( ParseException exp ) {
      Logger.getLogger("azureus2").error("Parsing failed.  Reason: " + exp.getMessage(), exp);
      if (constart)
        System.exit(2);
    }
    if (commands.hasOption('h')) {
      if (constart) {
        HelpFormatter hf = new HelpFormatter();
        hf.printHelp("java org.gudy.azureus2.ui.common.Main", "Optionally you can put torrent files to add to the end of the command line.\r\n", options, "Available User Interfaces: swt (default), web, console\r\nThe default interface is not started if you give either the '-e' or '-c' option (But you can start it by hand with '-u').", true);
        System.exit(0);
      }
View Full Code Here

    boolean mi = mi_str != null && mi_str.equalsIgnoreCase("true");

    initRootLogger();
   
    try{
         CommandLine commands = parseCommands(args, true);

         if ( commands != null && directLaunch( args, commands )){
          
           return;
         }
View Full Code Here

    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

    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

  {
    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

    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

    // 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

                    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

    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

TOP

Related Classes of org.apache.commons.cli.CommandLine

Copyright © 2015 www.massapicom. 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.