--- a/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java Mon Dec 16 20:01:37 2013 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java Mon Dec 16 20:20:54 2013 +0100
@@ -38,8 +38,8 @@
/** Show info */
if (!options.getShowInfo().isEmpty()) {
- InfoLister infoLister = new InfoLister();
- infoLister.showInfo(options, System.err);
+ InfoLister infoLister = new InfoLister(System.err);
+ infoLister.showInfo(options);
}
} catch (CLIParserException e) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/java/sql-dk/src/info/globalcode/sql/dk/Constants.java Mon Dec 16 20:20:54 2013 +0100
@@ -0,0 +1,30 @@
+/**
+ * SQL-DK
+ * Copyright © 2013 František Kučera (frantovo.cz)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package info.globalcode.sql.dk;
+
+/**
+ *
+ * @author Ing. František Kučera (frantovo.cz)
+ */
+public class Constants {
+
+ public static final String WEBSITE = "https://sql-dk.globalcode.info/";
+
+ private Constants() {
+ }
+}
--- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Mon Dec 16 20:01:37 2013 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Mon Dec 16 20:20:54 2013 +0100
@@ -17,8 +17,12 @@
*/
package info.globalcode.sql.dk;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.EnumSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* Displays info like help, version etc.
@@ -27,7 +31,14 @@
*/
public class InfoLister {
- public void showInfo(CLIOptions options, PrintStream out) {
+ private static final Logger log = Logger.getLogger(InfoLister.class.getName());
+ private PrintStream out;
+
+ public InfoLister(PrintStream out) {
+ this.out = out;
+ }
+
+ public void showInfo(CLIOptions options) {
EnumSet<CLIOptions.INFO_TYPE> infoTypes = options.getShowInfo();
for (CLIOptions.INFO_TYPE infoType : infoTypes) {
switch (infoType) {
@@ -35,29 +46,48 @@
* TODO: implement show info
*/
case FORMATTERS:
- out.println("TODO: list available formatters");
+ println("TODO: list available formatters");
break;
case HELP:
- out.println("TODO: show some help");
+ println("TODO: show some help");
break;
case LICENSE:
- out.println("TODO: show license");
+ printLicense();
break;
case TYPES:
- out.println("TODO: list supported types");
+ println("TODO: list supported types");
break;
case VERSION:
- out.println("TODO: show version");
+ println("TODO: show version");
break;
case DATABASES:
- out.println("TODO: list databases");
+ println("TODO: list databases");
break;
case CONNECTION:
- out.println("TODO: test database connection: " + options.getDatabaseNameToTest());
+ println("TODO: test database connection: " + options.getDatabaseNameToTest());
break;
default:
throw new IllegalArgumentException("Unsupported INFO_TYPE: " + infoType);
}
}
}
+
+ private void printLicense() {
+ try (BufferedReader license = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("info/globalcode/sql/dk/license.txt")))) {
+ while (true) {
+ String line = license.readLine();
+ if (line == null) {
+ break;
+ } else {
+ println(line);
+ }
+ }
+ } catch (Exception e) {
+ log.log(Level.SEVERE, "Unable to print license. See our website for license information.", e);
+ }
+ }
+
+ private void println(String line) {
+ out.println(line);
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/java/sql-dk/src/info/globalcode/sql/dk/license.txt Mon Dec 16 20:20:54 2013 +0100
@@ -0,0 +1,1 @@
+../../../../../../../license/gpl.txt
\ No newline at end of file