001: /*
002: * AppArguments.java
003: *
004: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
005: *
006: * Copyright 2002-2007, Thomas Kellerer
007: * No part of this code maybe reused without the permission of the author
008: *
009: * To contact the author please send an email to: support@sql-workbench.net
010: *
011: */
012: package workbench;
013:
014: import java.util.List;
015: import workbench.util.ArgumentParser;
016: import workbench.util.ArgumentType;
017:
018: /**
019: * @author support@sql-workbench.net
020: */
021: public class AppArguments extends ArgumentParser {
022: // Parameters for batch execution used by BatchRunner
023: public static final String ARG_SCRIPT = "script";
024: public static final String ARG_SCRIPT_ENCODING = "encoding";
025: public static final String ARG_ABORT = "abortOnError";
026:
027: // Connection related parameters
028: public static final String ARG_PROFILE = "profile";
029: public static final String ARG_PROFILE_GROUP = "profilegroup";
030: public static final String ARG_CONN_URL = "url";
031: public static final String ARG_CONN_DRIVER = "driver";
032: public static final String ARG_CONN_JAR = "driverjar";
033: public static final String ARG_CONN_USER = "username";
034: public static final String ARG_CONN_PWD = "password";
035: public static final String ARG_CONN_AUTOCOMMIT = "autocommit";
036: public static final String ARG_CONN_ROLLBACK = "rollbackOnDisconnect";
037: public static final String ARG_CONN_TRIM_CHAR = "trimCharData";
038: public static final String ARG_IGNORE_DROP = "ignoreDropErrors";
039:
040: public static final String ARG_DISPLAY_RESULT = "displayResult";
041: public static final String ARG_SUCCESS_SCRIPT = "cleanupSuccess";
042: public static final String ARG_ERROR_SCRIPT = "cleanupError";
043: public static final String ARG_SHOW_TIMING = "showTiming";
044: public static final String ARG_FEEDBACK = "feedback";
045: public static final String ARG_WORKSPACE = "workspace";
046: public static final String ARG_ALT_DELIMITER = "altDelimiter";
047: public static final String ARG_DELIMITER = "delimiter";
048: public static final String ARG_CONSOLIDATE_LOG = "consolidateMessages";
049:
050: // Other parameters
051: public static final String ARG_SHOWPROGRESS = "showProgress";
052: public static final String ARG_QUIET = "quiet";
053: public static final String ARG_PROFILE_STORAGE = "profileStorage";
054: public static final String ARG_CONFIGDIR = "configDir";
055: public static final String ARG_LIBDIR = "libdir";
056: public static final String ARG_LOGFILE = "logfile";
057: public static final String ARG_VARDEF = "varDef";
058: public static final String ARG_SHOW_PUMPER = "dataPumper";
059: public static final String ARG_SHOW_DBEXP = "dbExplorer";
060: public static final String ARG_LANG = "languaqe";
061: public static final String ARG_NOSETTNGS = "noSettings";
062: public static final String ARG_NOTEMPLATES = "noTemplates";
063:
064: public AppArguments() {
065: addArgument(ARG_PROFILE, ArgumentType.ProfileArgument);
066: addArgument(ARG_FEEDBACK);
067: addArgument(ARG_PROFILE_GROUP);
068: addArgument(ARG_PROFILE_STORAGE);
069: addArgument(ARG_CONFIGDIR);
070: addArgument(ARG_LIBDIR);
071: addArgument(ARG_SCRIPT);
072: addArgument(ARG_SCRIPT_ENCODING);
073: addArgument(ARG_LOGFILE);
074: addArgument(ARG_ABORT, ArgumentType.BoolArgument);
075: addArgument(ARG_SUCCESS_SCRIPT);
076: addArgument(ARG_ERROR_SCRIPT);
077: addArgument(ARG_VARDEF);
078: addArgument(ARG_CONN_URL);
079: addArgument(ARG_CONN_DRIVER);
080: addArgument(ARG_CONN_JAR);
081: addArgument(ARG_CONN_USER);
082: addArgument(ARG_CONN_PWD);
083: addArgument(ARG_CONN_AUTOCOMMIT, ArgumentType.BoolArgument);
084: addArgument(ARG_CONN_ROLLBACK, ArgumentType.BoolArgument);
085: addArgument(ARG_SHOW_PUMPER, ArgumentType.BoolArgument);
086: addArgument(ARG_IGNORE_DROP, ArgumentType.BoolArgument);
087: addArgument(ARG_DISPLAY_RESULT, ArgumentType.BoolArgument);
088: addArgument(ARG_SHOW_DBEXP, ArgumentType.BoolArgument);
089: addArgument(ARG_SHOW_TIMING, ArgumentType.BoolArgument);
090: addArgument(ARG_SHOWPROGRESS, ArgumentType.BoolArgument);
091: addArgument(ARG_WORKSPACE);
092: addArgument(ARG_NOSETTNGS, ArgumentType.BoolArgument);
093: addArgument(ARG_NOTEMPLATES, ArgumentType.BoolArgument);
094: addArgument(ARG_ALT_DELIMITER);
095: addArgument(ARG_DELIMITER);
096: addArgument(ARG_QUIET, ArgumentType.BoolArgument);
097: addArgument(ARG_CONN_TRIM_CHAR, ArgumentType.BoolArgument);
098: addArgument(ARG_LANG);
099: addArgument(ARG_CONSOLIDATE_LOG, ArgumentType.BoolArgument);
100: addArgument("help");
101: }
102:
103: public String getHelp() {
104: StringBuilder msg = new StringBuilder(100);
105: List<String> args = getRegisteredArguments();
106: msg.append("Available parameters:\n");
107: for (String arg : args) {
108: ArgumentType type = getArgumentType(arg);
109: msg.append("-" + arg);
110: if (type == ArgumentType.BoolArgument) {
111: msg.append(" (true/false)");
112: }
113: msg.append("\n");
114: }
115: return msg.toString();
116: }
117: }
|