Package gnu.getopt

Examples of gnu.getopt.Getopt


    String argString = "o:c:q:i:gd:f:b:";
    featdim = parseFeatDim(args, argString);
    dist = parseChunkDist(args, argString, featdim);
    parseCommands(args, argString);

    Getopt opt = new Getopt("VQComposer", args, argString);
    opt.setOpterr(false);

    int c = -1;
    while ((c = opt.getopt()) != -1)
    {
      switch (c)
      {
      case 'o':
        outFileName = opt.getOptarg();
        break;
      case 'g':
        debug = true;
        break;
      case 'q':
        cbSize = Integer.parseInt(opt.getOptarg());
        break;
      case 'b':
        beatsPerCodeword = Integer.parseInt(opt.getOptarg());
        break;
      case 'f':
        featsToQuantize = new FeatFile(opt.getOptarg());
        break;
      case 'c': // already handled above
        break;
      case 'd': // already handled above
        break;
      case 'i': // already handled above
        break;
      case '?':
        printUsageAndExit();
        break;
      default:
        System.out.print("getopt() returned " + c + "\n");
      }
    }

    // parse arguments
    int ind = opt.getOptind();
    if (ind > args.length)
      printUsageAndExit();

    trainFile = new FeatFile(args[args.length - 1]);
    if (featsToQuantize == null)
View Full Code Here


      String sopts = "c:f:hv";
      LongOpt[] lopts = new LongOpt[] { new LongOpt("connect", LongOpt.REQUIRED_ARGUMENT, null, 'c'),
            new LongOpt("file", LongOpt.REQUIRED_ARGUMENT, null, 'f'),
            new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
            new LongOpt("version", LongOpt.NO_ARGUMENT, null, 'v'), };
      Getopt g = new Getopt("ispn-cli", args, sopts, lopts);
      int c;
      while ((c = g.getopt()) != -1) {
         switch (c) {
         case 'c':
            Connection connection = ConnectionFactory.getConnection(g.getOptarg());
            String password = null;
            if (connection.needsCredentials()) {
               java.io.Console sysConsole = System.console();
               if (sysConsole != null) {
                  password = new String(sysConsole.readPassword("Password: "));
               } else {
                  exitWithError("Cannot read password non-interactively");
               }
            }
            connection.connect(password);
            context.setConnection(connection);
            break;
         case 'f':
            inputFile = g.getOptarg();
            if ("-".equals(inputFile) || new File(inputFile).isFile()) {
               mode = ShellMode.BATCH;
            } else {
               exitWithError("File '%s' doesn't exist or is not a file", g.getOptarg());
            }
            break;
         case 'h':
            help();
            break;
View Full Code Here

         new LongOpt("udp", LongOpt.REQUIRED_ARGUMENT, null, 'u'),
         new LongOpt("mcast_port", LongOpt.REQUIRED_ARGUMENT, null, 'm'),
         new LongOpt("log", LongOpt.REQUIRED_ARGUMENT, null, 'l'),
      };

      Getopt getopt = new Getopt(programName, args, sopts, lopts);
      int code;
      String arg;
      if (System.getProperty(ServerConfig.SERVER_BIND_ADDRESS) == null)
      {
         // ServerConfig.SERVER_BIND_ADDRESS could have been defined via
         // run.conf and so we don't wanna override that.
         props.setProperty(ServerConfig.SERVER_BIND_ADDRESS, "127.0.0.1");
         System.setProperty(ServerConfig.SERVER_BIND_ADDRESS, "127.0.0.1");
      }
      while ((code = getopt.getopt()) != -1)
      {
         switch (code)
         {
            case ':':
            case '?':
               // for now both of these should exit with error status
               System.exit(1);
               break; // for completeness

            case 1:
               // this will catch non-option arguments
               // (which we don't currently care about)
               System.err.println(programName +
                                  ": unused non-option argument: " +
                                  getopt.getOptarg());
               break; // for completeness

            case 'h':
               // show command line help
               System.out.println("usage: " + programName + " [options]");
               System.out.println();
               System.out.println("options:");
               System.out.println("    -h, --help                    Show this help message");
               System.out.println("    -V, --version                 Show version information");
               System.out.println("    --                            Stop processing options");
               System.out.println("    -D<name>[=<value>]            Set a system property");
               System.out.println("    -d, --bootdir=<dir>           Set the boot patch directory; Must be absolute or url");
               System.out.println("    -p, --patchdir=<dir>          Set the patch directory; Must be absolute or url");
               System.out.println("    -n, --netboot=<url>           Boot from net with the given url as base");
               System.out.println("    -c, --configuration=<name>    Set the server configuration name");
               System.out.println("    -B, --bootlib=<filename>      Add an extra library to the front bootclasspath");
               System.out.println("    -L, --library=<filename>      Add an extra library to the loaders classpath");
               System.out.println("    -C, --classpath=<url>         Add an extra url to the loaders classpath");
               System.out.println("    -P, --properties=<url>        Load system properties from the given url");
               System.out.println("    -b, --host=<host or ip>       Bind address for all JBoss services");
               System.out.println("    -g, --partition=<name>        HA Partition name (default=DefaultDomain)");
               System.out.println("    -m, --mcast_port=<ip>         UDP multicast port; only used by JGroups");
               System.out.println("    -u, --udp=<ip>                UDP multicast address");
               System.out.println("    -l, --log=<log4j|jdk>         Specify the logger plugin type");
               System.out.println();
               System.exit(0);
               break; // for completeness

            case 'D':
            {
               // set a system property
               arg = getopt.getOptarg();
               String name, value;
               int i = arg.indexOf("=");
               if (i == -1)
               {
                  name = arg;
                  value = "true";
               }
               else
               {
                  name = arg.substring(0, i);
                  value = arg.substring(i + 1, arg.length());
               }
               System.setProperty(name, value);
               // Ensure setting the old bind.address property also sets the new
               // jgroups.bind_addr property, otherwise jgroups may ignore it
               if ("bind.address".equals(name))
               {
                  // Wildcard address is not valid for JGroups
                  String addr = ServerConfigUtil.fixRemoteAddress(value);
                  System.setProperty("jgroups.bind_addr", addr);
               }
               else if ("jgroups.bind_addr".equals(name))
               {
                  // Wildcard address is not valid for JGroups
                  String addr = ServerConfigUtil.fixRemoteAddress(value);
                  System.setProperty("jgroups.bind_addr", addr);
               }
               break;
            }

            case 'd':
               // set the boot patch URL
               bootURL = makeURL(getopt.getOptarg());
               break;

            case 'p':
            {
               // set the patch URL
               URL patchURL = makeURL(getopt.getOptarg());
               props.put(ServerConfig.PATCH_URL, patchURL.toString());

               break;
            }

            case 'n':
               // set the net boot url
               arg = getopt.getOptarg();

               // make sure there is a trailing '/'
               if (!arg.endsWith("/")) arg += "/";

               props.put(ServerConfig.HOME_URL, new URL(arg).toString());
               break;

            case 'c':
               // set the server name
               arg = getopt.getOptarg();
               props.put(ServerConfig.SERVER_NAME, arg);
               break;

            case 'V':
            {
               // Package information for org.jboss
               Package jbossPackage = Package.getPackage("org.jboss");

               // show version information
               System.out.println("JBoss " + jbossPackage.getImplementationVersion());
               System.out.println();
               System.out.println("Distributable under LGPL license.");
               System.out.println("See terms of license at gnu.org.");
               System.out.println();
               System.exit(0);
               break; // for completness
            }

            case 'j':
               // Show an error and exit
               System.err.println(programName + ": option '-j, --jaxp' no longer supported");
               System.exit(1);
               break; // for completness

            case 'B':
               arg = getopt.getOptarg();
               bootLibraries.add(arg);
               break;

            case 'L':
               arg = getopt.getOptarg();
               extraLibraries.add(arg);
               break;

            case 'C':
            {
               URL url = makeURL(getopt.getOptarg());
               extraClasspath.add(url);
               break;
            }

            case 'P':
            {
               // Set system properties from url/file
               URL url = makeURL(getopt.getOptarg());
               Properties props = System.getProperties();
               props.load(url.openConnection().getInputStream());
               break;
            }
            case 'b':
               arg = getopt.getOptarg();
               props.put(ServerConfig.SERVER_BIND_ADDRESS, arg);
               System.setProperty(ServerConfig.SERVER_BIND_ADDRESS, arg);
               // used by JGroups; only set if not set via -D so users
               // can use a different interface for cluster communication
               // There are 2 versions of this property, deprecated bind.address
               // and the new version, jgroups.bind_addr
               String bindAddress = System.getProperty("bind.address");
               if (bindAddress == null)
               {
                  // Wildcard address is not valid for JGroups
                  bindAddress = ServerConfigUtil.fixRemoteAddress(arg);
                  System.setProperty("bind.address", bindAddress);
               }
               bindAddress = System.getProperty("jgroups.bind_addr");
               if (bindAddress == null)
               {
                  // Wildcard address is not valid for JGroups
                  bindAddress = ServerConfigUtil.fixRemoteAddress(arg);
                  System.setProperty("jgroups.bind_addr", bindAddress);
               }
              
               // Set the java.rmi.server.hostname if not set
               String rmiHost = System.getProperty("java.rmi.server.hostname");
               if( rmiHost == null )
               {
                  rmiHost = ServerConfigUtil.fixRemoteAddress(arg);
                  System.setProperty("java.rmi.server.hostname", rmiHost);
               }
               break;
              
            case 'g':
               arg = getopt.getOptarg();
               props.put(ServerConfig.PARTITION_NAME_PROPERTY, arg);
               System.setProperty(ServerConfig.PARTITION_NAME_PROPERTY, arg);
               break;
              
            case 'u':
               arg = getopt.getOptarg();
               props.put(ServerConfig.PARTITION_UDP_PROPERTY, arg);
               System.setProperty(ServerConfig.PARTITION_UDP_PROPERTY, arg);
               // the new jgroups property name
               System.setProperty("jgroups.udp.mcast_addr", arg);
               break;
              
            case 'm':
               arg = getopt.getOptarg();
               props.put(ServerConfig.PARTITION_UDP_PORT_PROPERTY, arg);
               System.setProperty(ServerConfig.PARTITION_UDP_PORT_PROPERTY, arg);
               break;
              
            case 'l':
            {
               arg = getopt.getOptarg();
               String logPlugin = arg;
               if( arg.equalsIgnoreCase("log4j") )
                  logPlugin = "org.jboss.logging.Log4jLoggerPlugin";
               else if( arg.equalsIgnoreCase("jdk") )
                  logPlugin = "org.jboss.logging.jdk.JDK14LoggerPlugin";
View Full Code Here

         new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'),
         new LongOpt("extension", LongOpt.NO_ARGUMENT, null, 'e'),
         new LongOpt("load-consumer", LongOpt.NO_ARGUMENT, null, 'l'),
      };

      Getopt getopt = new Getopt(PROGRAM_NAME, args, shortOpts, longOpts);
      int c;
      while ((c = getopt.getopt()) != -1)
      {
         switch (c)
         {
            case 'b':
               bindingFiles.add(new File(getopt.getOptarg()));
               break;
            case 'k':
               generateSource = true;
               break;
            case 'c':
               catalog = new File(getopt.getOptarg());
               break;
            case 'p':
               targetPackage = getopt.getOptarg();
               break;
            case 'w':
               wsdlLocation = getopt.getOptarg();
               break;
            case 'o':
               outputDir = new File(getopt.getOptarg());
               break;
            case 's':
               sourceDir = new File(getopt.getOptarg());
               break;
            case 't':
               target = getopt.getOptarg();
               break;
            case 'q':
               quiet = true;
               break;
            case 'v':
               verbose = true;
               break;
            case 'l':
               loadConsumer = true;
               break;
            case 'e':
               extension = true;
               break;
            case 'h':
               printHelp();
               System.exit(0);
            case '?':
               System.exit(1);
         }
      }

      // debug output
      if(loadConsumer)
      {
         WSContractConsumer importer = WSContractConsumer.newInstance();
         System.out.println("WSContractConsumer instance: " + importer.getClass().getCanonicalName());
         System.exit(0);
      }

      int wsdlPos = getopt.getOptind();
      if (wsdlPos >= args.length)
      {
         System.err.println("Error: WSDL URL was not specified!");
         printHelp();
         System.exit(1);
View Full Code Here

         new LongOpt("quiet", LongOpt.NO_ARGUMENT, null, 'q'),
         new LongOpt("show-traces", LongOpt.NO_ARGUMENT, null, 't'),
         new LongOpt("load-provider", LongOpt.NO_ARGUMENT, null, 'l'),
      };
     
      Getopt getopt = new Getopt(PROGRAM_NAME, args, shortOpts, longOpts);
      int c;
      while ((c = getopt.getopt()) != -1)
      {
         switch (c)
         {
            case 'k':
               generateSource = true;
               break;
            case 's':
               sourceDir = new File(getopt.getOptarg());
               break;
            case 'r':
               resourceDir = new File(getopt.getOptarg());
               break;
            case 'w':
               generateWsdl = true;
               break;
            case 't':
               showTraces = true;
               break;
            case 'o':
               outputDir = new File(getopt.getOptarg());
               break;
            case 'q':
               quiet = true;
               break;
            case 'c':
               processClassPath(getopt.getOptarg());
               break;
            case 'l':
               loadProvider = true;
               break;
            case 'h':
               printHelp();
               System.exit(0);
            case '?':
               System.exit(1);
         }
      }

      // debug output
      if(loadProvider)
      {
         WSContractProvider gen = WSContractProvider.newInstance(loader);
         System.out.println("WSContractProvider instance: " + gen.getClass().getCanonicalName());
         System.exit(0);
      }

      int endpointPos = getopt.getOptind();
      if (endpointPos >= args.length)
      {
         System.err.println("Error: endpoint implementation was not specified!");
         printHelp();
         System.exit(1);
View Full Code Here

  }

   public static void main(String argv[]) throws Exception {
      XSDoc xsDoc = new XSDoc();
      String outputDir = System.getProperty("user.dir");
      Getopt opts = new Getopt("xsdoc", argv, "o:");
      for (int opt = opts.getopt(); opt > -1; opt = opts.getopt()) {
         switch (opt) {
         case 'o':
            outputDir = opts.getOptarg();
            break;
         }
      }
      File outDir = new File(outputDir);
      outDir.mkdirs();
      for (int i = opts.getOptind(); i < argv.length; i++) {
         xsDoc.transform(argv[i], outDir);
      }

      xsDoc.generateIndex(outDir);
   }
View Full Code Here

      String sopts = "c:f:hv";
      LongOpt[] lopts = new LongOpt[] { new LongOpt("connect", LongOpt.REQUIRED_ARGUMENT, null, 'c'),
            new LongOpt("file", LongOpt.REQUIRED_ARGUMENT, null, 'f'),
            new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
            new LongOpt("version", LongOpt.NO_ARGUMENT, null, 'v'), };
      Getopt g = new Getopt("ispn-cli", args, sopts, lopts);
      int c;
      while ((c = g.getopt()) != -1) {
         switch (c) {
         case 'c':
            Connection connection = ConnectionFactory.getConnection(g.getOptarg());
            String password = null;
            if (connection.needsCredentials()) {
               java.io.Console sysConsole = System.console();
               if (sysConsole != null) {
                  password = new String(sysConsole.readPassword("Password: "));
               } else {
                  exitWithError("Cannot read password non-interactively");
               }
            }
            connection.connect(context, password);
            context.setConnection(connection);
            break;
         case 'f':
            inputFile = g.getOptarg();
            if ("-".equals(inputFile) || new File(inputFile).isFile()) {
               mode = ShellMode.BATCH;
            } else {
               exitWithError("File '%s' doesn't exist or is not a file", g.getOptarg());
            }
            break;
         case 'h':
            help();
            break;
View Full Code Here

     */
    public static Vector parseFeatureExtractor(String[] args, String argString)
    {
        Vector featExts = new Vector();

        Getopt opt = new Getopt("MEAPUtil", args, argString);
        opt.setOpterr(false);
       
        int c = -1;
        while ((c = opt.getopt()) != -1)
        {
            if(c == 'f')
            {
                String featName = opt.getOptarg();
               
                // Try to load the class named featName that extends
                // featextractors.FeatureExtractor.  (This is ugly as
                // hell)
                Class cl = null;
View Full Code Here

    {
        if(args.length == 0)
            printUsageAndExit();
       
        // Parse arguments
        Getopt opt = new Getopt("Segmenter", args, "m:t:do:s:0");
        opt.setOpterr(false);
       
        int c = -1;
        while ((c = opt.getopt()) != -1)
        {
            switch(c)
            {
            case 'm':
                mixerToUse = Integer.parseInt(opt.getOptarg());
                System.out.println("Using mixer " + mixerToUse);
                break;
            case 't':
                threshMult = Double.parseDouble(opt.getOptarg());
                tempoMult = threshMult;
                break;
            case 's':
                smtime = Double.parseDouble(opt.getOptarg());
                break;
            case 'd':
                useBeatOD = false;
                break;
            case 'o':
                outFileName = opt.getOptarg();
                break;
            case '0':
                onsetAtFirstFrame = true;
                break;
            case '?':
                printUsageAndExit();
                break;
            default:
                System.out.print("getopt() returned " + c + "\n");
            }
        }
       
        // parse arguments
        int ind = opt.getOptind();
        if(ind > args.length)
            printUsageAndExit();
       
        audioFiles = new String[args.length - ind];
        for(int i=ind; i<args.length; i++)
View Full Code Here

    {
        if(args.length == 0)
            printUsageAndExit();

        // Parse arguments
        Getopt opt = new Getopt("Synthesizer", args, "o:");
        opt.setOpterr(false);
       
        int c = -1;
        while ((c = opt.getopt()) != -1)
        {
            switch(c)
            {
            case 'o':
                outFile = opt.getOptarg();
                break;
            case '?':
                printUsageAndExit();
                break;
            default:
                System.out.print("getopt() returned " + c + "\n");
            }
        }
       
        // parse arguments
        int ind = opt.getOptind();
        if(ind > args.length)
            printUsageAndExit();
       
        edlFile = new EDLFile(args[ind]);
View Full Code Here

TOP

Related Classes of gnu.getopt.Getopt

Copyright © 2018 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.