Package com.darwinsys.lang

Examples of com.darwinsys.lang.GetOpt


   */
  public static void main(final String[] args) {
    String config = "default";
    String outputModeName = "t";
    String outputFile = null;
    final GetOpt go = new GetOpt("dvf:c:m:o:");
    char c;
    while ((c = go.getopt(args)) != GetOpt.DONE) {
      switch(c) {
      case 'h':
        doHelp(0);
        break;
      case 'd':
        SQLRunner.setVerbosity(Verbosity.DEBUG);
        break;
      case 'v':
        SQLRunner.setVerbosity(Verbosity.VERBOSE);
        break;
      case 'f':
        ConnectionUtil.setConfigFileName(go.optarg());
        break;
      case 'c':
        config = go.optarg();
        break;
      case 'm':
        outputModeName = go.optarg();
        break;
      case 'o':
        outputFile = go.optarg();
        break;
      default:
        System.err.println("Unknown option character " + c);
        doHelp(1);
      }
    }

    try {

      Configuration conf = ConnectionUtil.getConfiguration(config);
      if (!conf.hasPassword()) {
        System.err.printf("Enter password for connection %s: ", config);
        System.err.flush();
        Scanner sc = new Scanner(System.in);      // Requires J2SE 1.5
              String newPass = sc.next();
        conf.setPassword(newPass);
      }
      Connection conn = ConnectionUtil.getConnection(conf);


      SQLRunner prog = new SQLRunner(conn, outputFile, outputModeName);

      if (go.getOptInd() == args.length) {
        runScript(prog, new BufferedReader(
          new InputStreamReader(System.in)), "(standard input)");
      } else for (int i = go.getOptInd()-1; i < args.length; i++) {
        runScript(prog, args[i]);
      }
      prog.close();
    } catch (SQLException ex) {
      throw new DataBaseException(ex.toString());
View Full Code Here

TOP

Related Classes of com.darwinsys.lang.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.