author | František Kučera <franta-hg@frantovo.cz> |
Fri, 27 Dec 2013 15:58:46 +0100 | |
branch | v_0 |
changeset 78 | d98f33d91553 |
parent 77 | 9ec901d13a14 |
child 79 | e19a13ed19a9 |
permissions | -rw-r--r-- |
16
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
1 |
/** |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
2 |
* SQL-DK |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
3 |
* Copyright © 2013 František Kučera (frantovo.cz) |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
4 |
* |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
8 |
* (at your option) any later version. |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
9 |
* |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
13 |
* GNU General Public License for more details. |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
14 |
* |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
17 |
*/ |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
package info.globalcode.sql.dk; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
|
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
68
diff
changeset
|
20 |
import info.globalcode.sql.dk.InfoLister.InfoType; |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
21 |
import java.util.ArrayList; |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
22 |
import java.util.HashMap; |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
23 |
import java.util.List; |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
24 |
import java.util.Map; |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
25 |
|
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
/** |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
* |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
* @author Ing. František Kučera (frantovo.cz) |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
*/ |
5 | 30 |
public class CLIParser { |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
|
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
32 |
public static final String TYPE_NAME_SEPARATOR = ":"; |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
33 |
|
9 | 34 |
public CLIOptions parseOptions(String[] args) throws CLIParserException { |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
CLIOptions options = new CLIOptions(); |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
|
68
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
37 |
List<SQLType> numberedTypes = new ArrayList<>(); |
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
38 |
Map<String, SQLType> namedTypes = new HashMap<>(); |
2 | 39 |
|
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
for (int i = 0; i < args.length; i++) { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
String arg = args[i]; |
2 | 42 |
switch (arg) { |
43 |
case Tokens.TYPES: |
|
8 | 44 |
String typesString = fetchNext(args, ++i); |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
45 |
|
10 | 46 |
for (String oneType : typesString.split(",")) { |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
47 |
int sepatratorIndex = oneType.indexOf(TYPE_NAME_SEPARATOR); |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
48 |
if (sepatratorIndex == -1) { |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
49 |
numberedTypes.add(getType(oneType)); |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
50 |
} else { |
12
2dcb67d90fd2
unit-test: names, types, prefix
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
51 |
String namePart = oneType.substring(0, sepatratorIndex).trim(); |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
52 |
String typePart = oneType.substring(sepatratorIndex + TYPE_NAME_SEPARATOR.length(), oneType.length()); |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
53 |
namedTypes.put(namePart, getType(typePart)); |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
54 |
} |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
55 |
} |
2 | 56 |
break; |
57 |
case Tokens.NAME_PREFIX: |
|
8 | 58 |
options.setNamePrefix(fetchNext(args, ++i)); |
2 | 59 |
break; |
44
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
60 |
case Tokens.NAME_SUFFIX: |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
61 |
options.setNameSuffix(fetchNext(args, ++i)); |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
62 |
break; |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
case Tokens.DB: |
8 | 64 |
options.setDatabaseName(fetchNext(args, ++i)); |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
break; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
case Tokens.SQL: |
8 | 67 |
options.setSql(fetchNext(args, ++i)); |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
break; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
case Tokens.BATCH: |
2 | 70 |
options.setBatch(true); |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
71 |
break; |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
72 |
case Tokens.DATA: // --data is the last option |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
73 |
for (i++; i < args.length; i++) { |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
74 |
arg = args[i]; |
52
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
75 |
Parameter parameter; |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
76 |
if (numberedTypes.isEmpty()) { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
77 |
parameter = new Parameter(arg, null); |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
78 |
} else { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
79 |
int paramIndex = options.getNumberedParameters().size(); |
68
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
80 |
SQLType paramType; |
52
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
81 |
try { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
82 |
paramType = numberedTypes.get(paramIndex); |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
83 |
} catch (IndexOutOfBoundsException e) { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
84 |
throw new CLIParserException("Missing type for parameter #" + paramIndex, e); |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
85 |
} catch (NullPointerException e) { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
86 |
throw new CLIParserException("Invalid type definition for parameter #" + paramIndex, e); |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
87 |
} |
52
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
88 |
parameter = new Parameter(arg, paramType); |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
89 |
} |
52
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
90 |
options.addNumberedParameter(parameter); |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
91 |
} |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
92 |
break; |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
93 |
case Tokens.DATA_NAMED: |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
94 |
for (i++; i < args.length; i++) { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
95 |
String paramName = args[i]; |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
96 |
String paramValue = fetchNext(args, ++i); |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
97 |
options.addNamedParameter(new NamedParameter(paramName, paramValue, namedTypes.get(paramName))); |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
98 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
99 |
break; |
14 | 100 |
case Tokens.FORMATTER: |
101 |
options.setFormatterName(fetchNext(args, ++i)); |
|
102 |
break; |
|
103 |
case Tokens.INFO_HELP: |
|
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
68
diff
changeset
|
104 |
options.addShowInfo(InfoType.HELP); |
14 | 105 |
break; |
106 |
case Tokens.INFO_FORMATTERS: |
|
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
68
diff
changeset
|
107 |
options.addShowInfo(InfoType.FORMATTERS); |
14 | 108 |
break; |
109 |
case Tokens.INFO_LICENSE: |
|
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
68
diff
changeset
|
110 |
options.addShowInfo(InfoType.LICENSE); |
14 | 111 |
break; |
112 |
case Tokens.INFO_TYPES: |
|
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
68
diff
changeset
|
113 |
options.addShowInfo(InfoType.TYPES); |
14 | 114 |
break; |
115 |
case Tokens.INFO_VERSION: |
|
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
68
diff
changeset
|
116 |
options.addShowInfo(InfoType.VERSION); |
14 | 117 |
break; |
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
118 |
case Tokens.INFO_DATABASES: |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
68
diff
changeset
|
119 |
options.addShowInfo(InfoType.DATABASES); |
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
120 |
break; |
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
121 |
case Tokens.INFO_CONNECTION: |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
68
diff
changeset
|
122 |
options.addShowInfo(InfoType.CONNECTION); |
74
a8444f6a54f3
allow multiple databases connection test in --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
123 |
options.addDatabaseNameToTest(fetchNext(args, ++i)); |
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
124 |
break; |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
125 |
default: |
9 | 126 |
throw new CLIParserException("Unknown option: " + arg); |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
127 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
128 |
} |
8 | 129 |
return options; |
130 |
} |
|
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
131 |
|
9 | 132 |
private String fetchNext(String[] args, int index) throws CLIParserException { |
8 | 133 |
if (index < args.length) { |
134 |
return args[index]; |
|
135 |
} else { |
|
9 | 136 |
throw new CLIParserException("Expecting value for option: " + args[index - 1]); |
8 | 137 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
138 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
139 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
140 |
public static class Tokens { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
141 |
|
77
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
142 |
public static final String DB = "--db"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
143 |
public static final String SQL = "--sql"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
144 |
public static final String BATCH = "--batch"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
145 |
public static final String DATA = "--data"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
146 |
public static final String DATA_NAMED = "--data-named"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
147 |
public static final String NAME_PREFIX = "--name-prefix"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
148 |
public static final String NAME_SUFFIX = "--name-suffix"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
149 |
public static final String TYPES = "--types"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
150 |
public static final String FORMATTER = "--formatter"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
151 |
public static final String INFO_HELP = "--help"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
152 |
public static final String INFO_VERSION = "--version"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
153 |
public static final String INFO_LICENSE = "--license"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
154 |
public static final String INFO_FORMATTERS = "--list-formatters"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
155 |
public static final String INFO_TYPES = "--list-types"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
156 |
public static final String INFO_DATABASES = "--list-databases"; // bash-completion |
9ec901d13a14
tags for BASH completion
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
157 |
public static final String INFO_CONNECTION = "--test-connection"; // bash-completion |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
158 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
159 |
private Tokens() { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
160 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
161 |
} |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
162 |
|
68
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
163 |
private SQLType getType(String typeString) throws CLIParserException { |
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
164 |
try { |
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
165 |
return SQLType.valueOf(typeString.trim()); |
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
166 |
} catch (IllegalArgumentException e) { |
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
167 |
throw new CLIParserException("Unsupported type: " + typeString, e); |
8 | 168 |
} |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
169 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
170 |
} |