option --list-databases list configured databases v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 26 Dec 2013 01:29:29 +0100
branchv_0
changeset 666e28893eaada
parent 65 f05be87239ad
child 67 10c9b9e54622
option --list-databases list configured databases
java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Thu Dec 26 01:24:21 2013 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Thu Dec 26 01:29:29 2013 +0100
     1.3 @@ -25,6 +25,7 @@
     1.4  import java.io.PrintStream;
     1.5  import java.sql.SQLException;
     1.6  import java.util.EnumSet;
     1.7 +import java.util.List;
     1.8  import java.util.logging.Level;
     1.9  import java.util.logging.Logger;
    1.10  
    1.11 @@ -44,7 +45,7 @@
    1.12  		this.configurationProvider = configurationProvider;
    1.13  	}
    1.14  
    1.15 -	public void showInfo(CLIOptions options) {
    1.16 +	public void showInfo(CLIOptions options) throws ConfigurationException {
    1.17  		EnumSet<CLIOptions.INFO_TYPE> infoTypes = options.getShowInfo();
    1.18  		for (CLIOptions.INFO_TYPE infoType : infoTypes) {
    1.19  			switch (infoType) {
    1.20 @@ -67,7 +68,14 @@
    1.21  					printResource(Constants.VERSION_FILE);
    1.22  					break;
    1.23  				case DATABASES:
    1.24 -					println("TODO: list databases");
    1.25 +					final List<DatabaseDefinition> configuredDatabases = configurationProvider.getConfiguration().getDatabases();
    1.26 +					if (configuredDatabases.isEmpty()) {
    1.27 +						log.log(Level.WARNING, "No databases are configured.");
    1.28 +					} else {
    1.29 +						for (DatabaseDefinition dd : configuredDatabases) {
    1.30 +							log.log(Level.INFO, "Configured database: {0}", dd.getName());
    1.31 +						}
    1.32 +					}
    1.33  					break;
    1.34  				case CONNECTION:
    1.35  					boolean connectionTestResult = false;