equal
deleted
inserted
replaced
1 package info.globalcode.sql.dk; |
1 package info.globalcode.sql.dk; |
2 |
2 |
3 import static info.globalcode.sql.dk.Functions.isNotEmpty; |
3 import static info.globalcode.sql.dk.Functions.isNotEmpty; |
|
4 import static info.globalcode.sql.dk.Functions.isEmpty; |
4 import static info.globalcode.sql.dk.Functions.equalz; |
5 import static info.globalcode.sql.dk.Functions.equalz; |
5 import java.util.ArrayList; |
6 import java.util.ArrayList; |
6 import java.util.Collection; |
7 import java.util.Collection; |
7 import java.util.EnumSet; |
8 import java.util.EnumSet; |
8 import java.util.List; |
9 import java.util.List; |
14 public class CLIOptions { |
15 public class CLIOptions { |
15 |
16 |
16 public static final String DEFAULT_NAME_PREFIX = ":"; |
17 public static final String DEFAULT_NAME_PREFIX = ":"; |
17 private String sql; |
18 private String sql; |
18 private String databaseName; |
19 private String databaseName; |
|
20 private String databaseNameToTest; |
19 private String namePrefix = DEFAULT_NAME_PREFIX; |
21 private String namePrefix = DEFAULT_NAME_PREFIX; |
20 private String formatterName; |
22 private String formatterName; |
21 private boolean batch; |
23 private boolean batch; |
22 |
24 |
23 public enum MODE { |
25 public enum MODE { |
32 |
34 |
33 HELP, |
35 HELP, |
34 VERSION, |
36 VERSION, |
35 LICENSE, |
37 LICENSE, |
36 FORMATTERS, |
38 FORMATTERS, |
37 TYPES |
39 TYPES, |
|
40 DATABASES, |
|
41 CONNECTION |
38 } |
42 } |
39 |
43 |
40 public enum COMMAND_TYPE { |
44 public enum COMMAND_TYPE { |
41 |
45 |
42 /** SELECT */ |
46 /** SELECT */ |
74 if (isNotEmpty(formatterName, false)) { |
78 if (isNotEmpty(formatterName, false)) { |
75 e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify formatter if just showing info.")); |
79 e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify formatter if just showing info.")); |
76 } |
80 } |
77 if (!equalz(namePrefix, DEFAULT_NAME_PREFIX)) { |
81 if (!equalz(namePrefix, DEFAULT_NAME_PREFIX)) { |
78 e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify name prefix if just showing info.")); |
82 e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify name prefix if just showing info.")); |
|
83 } |
|
84 if (showInfo.contains(INFO_TYPE.CONNECTION) && isEmpty(databaseNameToTest, false)) { |
|
85 e.addProblem(new InvalidOptionsException.OptionProblem("Please specify which database should be tested.")); |
79 } |
86 } |
80 } |
87 } |
81 |
88 |
82 if (!namedParameters.isEmpty() && !numberedParameters.isEmpty()) { |
89 if (!namedParameters.isEmpty() && !numberedParameters.isEmpty()) { |
83 e.addProblem(new InvalidOptionsException.OptionProblem("Named and numbered parameters can not be used together in one command.")); |
90 e.addProblem(new InvalidOptionsException.OptionProblem("Named and numbered parameters can not be used together in one command.")); |
180 } |
187 } |
181 |
188 |
182 public EnumSet<INFO_TYPE> getShowInfo() { |
189 public EnumSet<INFO_TYPE> getShowInfo() { |
183 return showInfo; |
190 return showInfo; |
184 } |
191 } |
|
192 |
|
193 public String getDatabaseNameToTest() { |
|
194 return databaseNameToTest; |
|
195 } |
|
196 |
|
197 public void setDatabaseNameToTest(String databaseNameToTest) { |
|
198 this.databaseNameToTest = databaseNameToTest; |
|
199 } |
185 } |
200 } |