Examples of Getopt


Examples of org.apache.qpid.qmf2.util.GetOpt

            int port = 8080;
            String broker = null;
            int backlog = 10;
            String webroot = "qpid-web";

            GetOpt getopt = new GetOpt(args, "ha:i:p:b:w:", longOpts);
            List<String[]> optList = getopt.getOptList();
            String[] cargs = {};
            cargs = getopt.getEncArgs().toArray(cargs);

            for (String[] opt : optList)
            {
                if (opt[0].equals("-h") || opt[0].equals("--help"))
                {
View Full Code Here

Examples of org.apache.xalan.xsltc.cmdline.getopt.GetOpt

    try {
      if (args.length == 0) {
        throw new Exception("no arguments specified.");
      }

      GetOpt getopt = new GetOpt(args, "i:s:h");
      while ( (c = getopt.getNextOption()) != -1) {
        switch (c) {
          case 'i':
            this.inputFile = getopt.getOptionArg();
            File f = new File(this.inputFile);
            if (!f.exists())
              usage("input file missing: " + this.inputFile);
            break;
          case 's':
            this.schemaFile = getopt.getOptionArg();
            File s = new File(this.schemaFile);
            break;
          case 'h':
            usage(null);
            break;
View Full Code Here

Examples of org.apache.xalan.xsltc.cmdline.getopt.GetOpt

    public static void main(String[] args) {
  try {
      boolean inputIsURL = false;
      boolean useStdIn = false;
      boolean classNameSet = false;
      final GetOpt getopt = new GetOpt(args, "o:d:j:p:uxhsinv");
      if (args.length < 1) printUsage();

      final XSLTC xsltc = new XSLTC();
      xsltc.init();

      int c;
      while ((c = getopt.getNextOption()) != -1) {
    switch(c) {
    case 'i':
        useStdIn = true;
        break;
    case 'o':
        xsltc.setClassName(getopt.getOptionArg());
        classNameSet = true;
        break;
    case 'd':
        xsltc.setDestDirectory(getopt.getOptionArg());
        break;
    case 'p':
        xsltc.setPackageName(getopt.getOptionArg());
        break;
    case 'j'
        xsltc.setJarFileName(getopt.getOptionArg());
        break;
    case 'x':
        xsltc.setDebug(true);
        break;
    case 'u':
        inputIsURL = true;
        break;
    case 'n':
        xsltc.setTemplateInlining(true)// used to be 'false'
        break;
    case 'v':
        // fall through to case h
    case 'h':
    default:
        printUsage();
        break;
    }
      }

      boolean compileOK;

      if (useStdIn) {
    if (!classNameSet) {
        System.err.println(new ErrorMsg(ErrorMsg.COMPILE_STDIN_ERR));
    }
    compileOK = xsltc.compile(System.in, xsltc.getClassName());
      }
      else {
    // Generate a vector containg URLs for all stylesheets specified
    final String[] stylesheetNames = getopt.getCmdArgs();
    final Vector   stylesheetVector = new Vector();
    for (int i = 0; i < stylesheetNames.length; i++) {
        final String name = stylesheetNames[i];
        URL url;
        if (inputIsURL)
View Full Code Here

Examples of org.apache.xalan.xsltc.cmdline.getopt.GetOpt

    public static void main(String[] args) {
  try {
      boolean inputIsURL = false;
      boolean useStdIn = false;
      boolean classNameSet = false;
      final GetOpt getopt = new GetOpt(args, "o:d:j:p:uxhsinv");
      if (args.length < 1) printUsage();

      final XSLTC xsltc = new XSLTC();
      xsltc.init();

      int c;
      while ((c = getopt.getNextOption()) != -1) {
    switch(c) {
    case 'i':
        useStdIn = true;
        break;
    case 'o':
        xsltc.setClassName(getopt.getOptionArg());
        classNameSet = true;
        break;
    case 'd':
        xsltc.setDestDirectory(getopt.getOptionArg());
        break;
    case 'p':
        xsltc.setPackageName(getopt.getOptionArg());
        break;
    case 'j'
        xsltc.setJarFileName(getopt.getOptionArg());
        break;
    case 'x':
        xsltc.setDebug(true);
        break;
    case 'u':
        inputIsURL = true;
        break;
    case 'n':
        xsltc.setTemplateInlining(true)// used to be 'false'
        break;
    case 'v':
        // fall through to case h
    case 'h':
    default:
        printUsage();
        break;
    }
      }

      boolean compileOK;

      if (useStdIn) {
    if (!classNameSet) {
        System.err.println(new ErrorMsg(ErrorMsg.COMPILE_STDIN_ERR));
    }
    compileOK = xsltc.compile(System.in, xsltc.getClassName());
      }
      else {
    // Generate a vector containg URLs for all stylesheets specified
    final String[] stylesheetNames = getopt.getCmdArgs();
    final Vector   stylesheetVector = new Vector();
    for (int i = 0; i < stylesheetNames.length; i++) {
        final String name = stylesheetNames[i];
        URL url;
        if (inputIsURL)
View Full Code Here

Examples of org.hivedb.util.GetOpt

      throw new HiveRuntimeException(e.getMessage(), e);
    }
  }

  public static void main(String[] argz) {
    GetOpt opt = new GetOpt();
    opt.add("host", true);
    opt.add("db", true);
    opt.add("user", true);
    opt.add("pw", true);

    Map<String, String> argMap = opt.toMap(argz);
    if (!opt.validate())
      throw new IllegalArgumentException(
        "Usage: java -jar hivedb-installer.jar -host <host> -db <database name> -user <username> -pw <password>");
    else {
      try {
        //Tickle driver
View Full Code Here

Examples of org.jostraca.comp.gnu.getopt.Getopt

    ArrayList    additionalConfigFiles     = new ArrayList();
    ArrayList    cmdlinetemplates          = new ArrayList();


    // parse command line
    Getopt g = new Getopt( CMD_NAME, pArgs, ":"+CMD_SPEC_Options );
    g.setOpterr( false ); // handle errors manually
    int    c;
    String arg;

    while( -1 != ( c = g.getopt() ) ) {

      switch( c ) {

      case ARG_CONFIG : // configuration file
        configPath = g.getOptarg();
        usingDefaultConf = false;
        break;

      case ARG_ADD_CONFIG : // additional configuration file
        String addConfigPath = g.getOptarg();
        pAdditionalConfig.add( addConfigPath );
        break;

      case ARG_WRITER_FORMAT : // writer format
        String writerFormatPath = g.getOptarg().trim();
        checkDataFile( "WriterFormat", writerFormatPath );
        cmdLineOptions.set( Property.main_CodeWriterFormat, writerFormatPath );
        break;

      case ARG_TEMPLATE_DOC : // show documentation
        cmdLineOptions.set( Property.main_ShowDocumentation, Standard.YES );
        break;

      case ARG_OUTPUT_FOLDER : // output folder
        String outputFolder = g.getOptarg().trim();
        checkFolder( "Output", outputFolder );
        cmdLineOptions.set( Property.main_OutputFolder, outputFolder );
        break;

      case ARG_WORK_FOLDER : // work folder
        String workFolder = g.getOptarg().trim();
        checkFolder( "Work", workFolder );
        cmdLineOptions.set( Property.main_WorkFolder, workFolder );
        break;

      case ARG_TEMPLATE_LIST : // templates listed in separate file
        String templateList = g.getOptarg().trim();
        checkDataFile( "Template list", templateList );
        addTemplatesFromFile( new File( templateList ), cmdlinetemplates );
        usingTemplateListFile = true;
        break;

      case ARG_ARGUMENT : // template arguments
        codeWriterOptions.append( g.getOptarg() );
        codeWriterOptions.append( Standard.SPACE );
        break;

      case ARG_ALL_TEMPLATES : // all arguments are templates
        argumentsAreTemplateNames = true;
        break;

      case ARG_BACKUP_FOLDER : // set backup folder and make backups
        String backupFolder = g.getOptarg().trim();
        cmdLineOptions.set( Property.main_BackupFolder, backupFolder );
        cmdLineOptions.set( Property.main_MakeBackup, Standard.YES );
        break;

      case ARG_NO_BACKUP : // don't backup
        cmdLineOptions.set( Property.main_MakeBackup, Standard.NO );
        break;

      case ARG_META_FOLDER : // set meta folder and store metadata
        String metaFolder = g.getOptarg().trim();
        cmdLineOptions.set( Property.main_MetaFolder, metaFolder );
        cmdLineOptions.set( Property.main_EnableMeta, Standard.YES );
        break;

      case ARG_NO_META : // don't store metadata
        cmdLineOptions.set( Property.main_EnableMeta, Standard.NO );
        break;

      case ARG_COMPILE : // compile code writer
        cmdLineOptions.set( Property.main_CompileCodeWriter, Standard.YES );
        break;

      case ARG_NO_COMPILE : // don't compile code writer
        cmdLineOptions.set( Property.main_CompileCodeWriter, Standard.NO );
        break;

      case ARG_GENERATE : // execute code writer, that is, generate output files
        cmdLineOptions.set( Property.main_ExecuteCodeWriter, Standard.YES );
        break;

      case ARG_NO_GENERATE : // don't execute code writer, that is, don't generate output files
        cmdLineOptions.set( Property.main_ExecuteCodeWriter, Standard.NO );
        break;

      case ARG_DUMP : // dump template, settings, etc
        String dumpSpec = g.getOptarg().trim();
        Service.parseDumpSpec( dumpSpec, cmdLineOptions );
        break;

      case ARG_DEFINE : // config setting
        // REVIEW: this parsing should be somewhere else, probably TextUtil
        String nameValue = g.getOptarg().trim();
        int equalsPos = nameValue.indexOf("=");
        if( -1 != equalsPos ) {
          cmdLineOptions.set
            ( nameValue.substring(0, equalsPos).trim(),
              nameValue.substring(equalsPos + 1).trim()
              );
        }
        break;

      case ARG_NON_STANDARD : // non-standard options
        String nsOptions = g.getOptarg();
        parseNonStandardOptions( nsOptions, cmdLineOptions, sUserMessageHandler );
        break;

      case ARG_LOW_VERBOSE : // low verbosity
        cmdLineOptions.set( Property.main_MessageLevel, UserMessageHandler.TypeNameUtil.getNameForType( UserMessageHandler.WARN ) );
        break;

      case ARG_HIGH_VERBOSE : // high verbosity
        cmdLineOptions.set( Property.main_MessageLevel, UserMessageHandler.TypeNameUtil.getNameForType( UserMessageHandler.DEBUG ) );
        break;

      case ':': // missing argument to option
        throw new JostracaException( "Option " + (char)g.getOptopt() + " requires an argument." );

      default: // everything else is a template or a template srgument
        break;
      }
    }
   
    // get template path specifiers and arguments
    int start   = g.getOptind();
    int numArgs = pArgs.length;
    for( int tpsI = start; tpsI < numArgs; tpsI++ ) {
      String argument = pArgs[tpsI].trim();
      if( ( ( !usingTemplateListFile && start == tpsI )
            || argumentsAreTemplateNames
View Full Code Here

Examples of org.netbeans.lib.cvsclient.commandLine.GetOpt

     *                      the command
     */
    private static int processGlobalOptions( String[] args, GlobalOptions globalOptions )
    {
        final String getOptString = globalOptions.getOptString();
        GetOpt go = new GetOpt( args, getOptString );
        int ch;
        while ( ( ch = go.getopt() ) != GetOpt.optEOF )
        {
            //System.out.println("Global option '"+((char) ch)+"',
            // '"+go.optArgGet()+"'");
            String arg = go.optArgGet();
            boolean success = globalOptions.setCVSCommand( (char) ch, arg );
            if ( !success )
            {
                throw new IllegalArgumentException( "Failed to set CVS Command: -" + ch + " = " + arg );
            }
        }

        return go.optIndexGet();
    }
View Full Code Here

Examples of org.opensolaris.opengrok.util.Getopt

    int nhits=0;

    @SuppressWarnings({"PMD.SwitchStmtsShouldHaveDefault"})
    protected boolean parseCmdLine(String[] argv) {
        engine = new SearchEngine();
        Getopt getopt = new Getopt(argv, "R:d:r:p:h:f:t:");
        try {
            getopt.parse();
        } catch (ParseException e) {
            System.err.println(e.getMessage());
            System.err.println(usage);
            return false;
        }

        int cmd;
        while ((cmd = getopt.getOpt()) != -1) {
            switch (cmd) {
                case 'R':
                    try {
                        RuntimeEnvironment.getInstance().readConfiguration(new File(getopt.getOptarg()));
                    } catch (IOException e) {
                        System.err.println("Failed to read config file: ");
                        System.err.println(e.getMessage());
                        return false;
                    }
                    break;
                case 'd':
                    engine.setDefinition(getopt.getOptarg());
                    break;
                case 'r':
                    engine.setSymbol(getopt.getOptarg());
                    break;
                case 'p':
                    engine.setFile(getopt.getOptarg());
                    break;
                case 'h':
                    engine.setHistory(getopt.getOptarg());
                    break;
                case 'f':
                    engine.setFreetext(getopt.getOptarg());
                    break;
                case 't':
                    engine.setType(getopt.getOptarg());
                    break;
            }
        }

        return true;
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.