java/sql-dk/src/main/java/info/globalcode/sql/dk/CLIStarter.java
author František Kučera <franta-hg@frantovo.cz>
Mon, 04 Mar 2019 20:15:24 +0100
branchv_0
changeset 238 4a1864c3e867
parent 221 java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java@e38910065d55
child 246 277c18b48762
permissions -rw-r--r--
mavenized: sql-dk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
26
4ec8e5534eb9 configuration basics
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
    20
import info.globalcode.sql.dk.configuration.ConfigurationProvider;
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    21
import info.globalcode.sql.dk.CLIOptions.MODE;
146
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
    22
import info.globalcode.sql.dk.batch.Batch;
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
    23
import info.globalcode.sql.dk.batch.BatchDecoder;
144
d273d7c6dc0c Batch: basic encoder and prepare batch
František Kučera <franta-hg@frantovo.cz>
parents: 106
diff changeset
    24
import info.globalcode.sql.dk.batch.BatchException;
d273d7c6dc0c Batch: basic encoder and prepare batch
František Kučera <franta-hg@frantovo.cz>
parents: 106
diff changeset
    25
import info.globalcode.sql.dk.batch.BatchEncoder;
26
4ec8e5534eb9 configuration basics
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
    26
import info.globalcode.sql.dk.configuration.Configuration;
33
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    27
import info.globalcode.sql.dk.configuration.ConfigurationException;
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
    28
import info.globalcode.sql.dk.configuration.DatabaseDefinition;
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
    29
import info.globalcode.sql.dk.configuration.FormatterDefinition;
189
f4d879cbcee1 separate configuration loading into the Loader class
František Kučera <franta-hg@frantovo.cz>
parents: 179
diff changeset
    30
import info.globalcode.sql.dk.configuration.Loader;
80
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
    31
import info.globalcode.sql.dk.configuration.NameIdentified;
220
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
    32
import info.globalcode.sql.dk.configuration.PropertyDeclaration;
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
    33
import info.globalcode.sql.dk.formatting.Formatter;
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
    34
import info.globalcode.sql.dk.formatting.FormatterContext;
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
    35
import info.globalcode.sql.dk.formatting.FormatterException;
179
236332caeb29 Basic JMX management/reporting – counters for commands and records
František Kučera <franta-hg@frantovo.cz>
parents: 166
diff changeset
    36
import info.globalcode.sql.dk.jmx.ConnectionManagement;
236332caeb29 Basic JMX management/reporting – counters for commands and records
František Kučera <franta-hg@frantovo.cz>
parents: 166
diff changeset
    37
import info.globalcode.sql.dk.jmx.ManagementUtils;
80
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
    38
import java.io.File;
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
    39
import java.io.FileNotFoundException;
33
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
    40
import java.io.IOException;
64
fcc499518dc7 use System.out if mode is JUST_SHOW_INFO (thus user can easily read license or help using … | less)
František Kučera <franta-hg@frantovo.cz>
parents: 63
diff changeset
    41
import java.io.PrintStream;
80
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
    42
import java.io.PrintWriter;
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
    43
import java.sql.SQLException;
80
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
    44
import java.util.Collection;
220
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
    45
import java.util.Collections;
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
    46
import java.util.List;
13
599aad77e986 fix: try/catch
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    47
import java.util.logging.Level;
63
3b9ec9c23a37 validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents: 56
diff changeset
    48
import java.util.logging.LogRecord;
13
599aad77e986 fix: try/catch
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    49
import java.util.logging.Logger;
599aad77e986 fix: try/catch
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    50
1
f32dac78d13a WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
/**
155
eb3676c6929b more JavaDoc
František Kučera <franta-hg@frantovo.cz>
parents: 149
diff changeset
    52
 * Entry point of the command line interface of SQL-DK.
1
f32dac78d13a WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
 *
f32dac78d13a WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
 * @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
    55
 */
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    56
public class CLIStarter implements ConfigurationProvider {
1
f32dac78d13a WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
96
7ae30649b30b basic generated help
František Kučera <franta-hg@frantovo.cz>
parents: 95
diff changeset
    58
	// help:exit-codes
95
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
    59
	public static final int EXIT_SUCCESS = 0; // doc:success
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
    60
	public static final int EXIT_UNEXPECTED_ERROR = 1; // doc:unexpected error (probably bug)
155
eb3676c6929b more JavaDoc
František Kučera <franta-hg@frantovo.cz>
parents: 149
diff changeset
    61
	// 2 is reserved: http://www.tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF
95
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
    62
	public static final int EXIT_SQL_ERROR = 3; // doc:SQL error
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
    63
	public static final int EXIT_CLI_PARSE_ERROR = 4; // doc:CLI options parse error
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
    64
	public static final int EXIT_CLI_VALIDATE_ERROR = 5; // doc:CLI options validation error
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
    65
	public static final int EXIT_CONFIGURATION_ERROR = 6; // doc:configuration error
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
    66
	public static final int EXIT_FORMATTING_ERROR = 7; // doc:formatting error
149
6a6f7b384591 Batch error – proper exit code: EXIT_BATCH_ERROR = 8
František Kučera <franta-hg@frantovo.cz>
parents: 146
diff changeset
    67
	public static final int EXIT_BATCH_ERROR = 8; // doc:batch error
13
599aad77e986 fix: try/catch
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    68
	private static final Logger log = Logger.getLogger(CLIStarter.class.getName());
189
f4d879cbcee1 separate configuration loading into the Loader class
František Kučera <franta-hg@frantovo.cz>
parents: 179
diff changeset
    69
	private final CLIOptions options;
f4d879cbcee1 separate configuration loading into the Loader class
František Kučera <franta-hg@frantovo.cz>
parents: 179
diff changeset
    70
	private final Loader configurationLoader = new Loader();
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    71
	private Configuration configuration;
13
599aad77e986 fix: try/catch
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    72
1
f32dac78d13a WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    73
	public static void main(String[] args) {
55
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents: 48
diff changeset
    74
		log.log(Level.FINE, "Starting " + Constants.PROGRAM_NAME);
95
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
    75
		int exitCode;
63
3b9ec9c23a37 validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents: 56
diff changeset
    76
21
d42ed0d10a10 CLI: --help is default option
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    77
		if (args.length == 0) {
d42ed0d10a10 CLI: --help is default option
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    78
			args = new String[]{CLIParser.Tokens.INFO_HELP};
d42ed0d10a10 CLI: --help is default option
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    79
		}
d42ed0d10a10 CLI: --help is default option
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    80
13
599aad77e986 fix: try/catch
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    81
		try {
599aad77e986 fix: try/catch
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    82
			CLIParser parser = new CLIParser();
166
5488c2dcf680 SQL from STDIN: --sql-in
František Kučera <franta-hg@frantovo.cz>
parents: 155
diff changeset
    83
			CLIOptions options = parser.parseOptions(args, System.in);
14
189b1260b942 show info basics
František Kučera <franta-hg@frantovo.cz>
parents: 13
diff changeset
    84
			options.validate();
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    85
			CLIStarter starter = new CLIStarter(options);
21
d42ed0d10a10 CLI: --help is default option
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    86
			starter.installDefaultConfiguration();
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    87
			starter.process();
55
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents: 48
diff changeset
    88
			log.log(Level.FINE, "All done");
56
29f45ab3b959 exit codes: 0 = success; 4 = SQL error; 3 = other expected error; 1 = unexpected error (implicit 1)
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
    89
			exitCode = EXIT_SUCCESS;
13
599aad77e986 fix: try/catch
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    90
		} catch (CLIParserException e) {
14
189b1260b942 show info basics
František Kučera <franta-hg@frantovo.cz>
parents: 13
diff changeset
    91
			log.log(Level.SEVERE, "Unable to parse CLI options", e);
95
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
    92
			exitCode = EXIT_CLI_PARSE_ERROR;
14
189b1260b942 show info basics
František Kučera <franta-hg@frantovo.cz>
parents: 13
diff changeset
    93
		} catch (InvalidOptionsException e) {
189b1260b942 show info basics
František Kučera <franta-hg@frantovo.cz>
parents: 13
diff changeset
    94
			log.log(Level.SEVERE, "Invalid CLI options", e);
48
28735e71a1da print CLI options problems if any
František Kučera <franta-hg@frantovo.cz>
parents: 42
diff changeset
    95
			for (InvalidOptionsException.OptionProblem p : e.getProblems()) {
63
3b9ec9c23a37 validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents: 56
diff changeset
    96
				LogRecord r = new LogRecord(Level.SEVERE, "Option problem: {0}");
3b9ec9c23a37 validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents: 56
diff changeset
    97
				r.setThrown(p.getException());
3b9ec9c23a37 validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents: 56
diff changeset
    98
				r.setParameters(new Object[]{p.getDescription()});
3b9ec9c23a37 validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents: 56
diff changeset
    99
				log.log(r);
48
28735e71a1da print CLI options problems if any
František Kučera <franta-hg@frantovo.cz>
parents: 42
diff changeset
   100
			}
95
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
   101
			exitCode = EXIT_CLI_VALIDATE_ERROR;
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   102
		} catch (ConfigurationException e) {
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   103
			log.log(Level.SEVERE, "Configuration problem", e);
95
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
   104
			exitCode = EXIT_CONFIGURATION_ERROR;
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   105
		} catch (SQLException e) {
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   106
			log.log(Level.SEVERE, "SQL problem", e);
56
29f45ab3b959 exit codes: 0 = success; 4 = SQL error; 3 = other expected error; 1 = unexpected error (implicit 1)
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
   107
			exitCode = EXIT_SQL_ERROR;
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   108
		} catch (FormatterException e) {
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   109
			log.log(Level.SEVERE, "Formatting problem", e);
95
714e4fac9cd0 more precise exit/error codes
František Kučera <franta-hg@frantovo.cz>
parents: 80
diff changeset
   110
			exitCode = EXIT_FORMATTING_ERROR;
144
d273d7c6dc0c Batch: basic encoder and prepare batch
František Kučera <franta-hg@frantovo.cz>
parents: 106
diff changeset
   111
		} catch (BatchException e) {
d273d7c6dc0c Batch: basic encoder and prepare batch
František Kučera <franta-hg@frantovo.cz>
parents: 106
diff changeset
   112
			log.log(Level.SEVERE, "Batch problem", e);
149
6a6f7b384591 Batch error – proper exit code: EXIT_BATCH_ERROR = 8
František Kučera <franta-hg@frantovo.cz>
parents: 146
diff changeset
   113
			exitCode = EXIT_BATCH_ERROR;
13
599aad77e986 fix: try/catch
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
   114
		}
56
29f45ab3b959 exit codes: 0 = success; 4 = SQL error; 3 = other expected error; 1 = unexpected error (implicit 1)
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
   115
29f45ab3b959 exit codes: 0 = success; 4 = SQL error; 3 = other expected error; 1 = unexpected error (implicit 1)
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
   116
		System.exit(exitCode);
4
f5c3350f3d78 data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
   117
	}
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   118
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   119
	public CLIStarter(CLIOptions options) {
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   120
		this.options = options;
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   121
	}
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   122
144
d273d7c6dc0c Batch: basic encoder and prepare batch
František Kučera <franta-hg@frantovo.cz>
parents: 106
diff changeset
   123
	private void process() throws ConfigurationException, SQLException, FormatterException, BatchException {
64
fcc499518dc7 use System.out if mode is JUST_SHOW_INFO (thus user can easily read license or help using … | less)
František Kučera <franta-hg@frantovo.cz>
parents: 63
diff changeset
   124
		MODE mode = options.getMode();
fcc499518dc7 use System.out if mode is JUST_SHOW_INFO (thus user can easily read license or help using … | less)
František Kučera <franta-hg@frantovo.cz>
parents: 63
diff changeset
   125
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   126
		/** Show info */
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   127
		if (!options.getShowInfo().isEmpty()) {
64
fcc499518dc7 use System.out if mode is JUST_SHOW_INFO (thus user can easily read license or help using … | less)
František Kučera <franta-hg@frantovo.cz>
parents: 63
diff changeset
   128
			PrintStream infoOut = mode == MODE.JUST_SHOW_INFO ? System.out : System.err;
69
0befec5034c2 InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents: 64
diff changeset
   129
			InfoLister infoLister = new InfoLister(infoOut, this, options);
70
02c8eaa425e8 use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents: 69
diff changeset
   130
			infoLister.showInfo();
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   131
		}
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   132
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   133
		switch (mode) {
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   134
			case QUERY_NOW:
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   135
				processQueryNow();
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   136
				break;
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   137
			case PREPARE_BATCH:
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   138
				processPrepareBatch();
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   139
				break;
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   140
			case EXECUTE_BATCH:
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   141
				processExecuteBatch();
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   142
				break;
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   143
			case JUST_SHOW_INFO:
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   144
				// already done above
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   145
				break;
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   146
			default:
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   147
				log.log(Level.SEVERE, "Unsupported mode: {0}", mode);
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   148
				break;
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   149
		}
80
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   150
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   151
		generateBashCompletion();
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   152
	}
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   153
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   154
	private void processQueryNow() throws ConfigurationException, SQLException, FormatterException {
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   155
		DatabaseDefinition dd = getConfiguration().getDatabase(options.getDatabaseName());
75
43aa4625ab7e throw ConfigurationException instead of returning null, if database or formatter of given name is not configured
František Kučera <franta-hg@frantovo.cz>
parents: 70
diff changeset
   156
		FormatterDefinition fd = configuration.getFormatter(options.getFormatterName());
179
236332caeb29 Basic JMX management/reporting – counters for commands and records
František Kučera <franta-hg@frantovo.cz>
parents: 166
diff changeset
   157
		ConnectionManagement jmxBean = ManagementUtils.registerMBean(dd.getName());
236332caeb29 Basic JMX management/reporting – counters for commands and records
František Kučera <franta-hg@frantovo.cz>
parents: 166
diff changeset
   158
236332caeb29 Basic JMX management/reporting – counters for commands and records
František Kučera <franta-hg@frantovo.cz>
parents: 166
diff changeset
   159
		try (DatabaseConnection c = dd.connect(options.getDatabaseProperties(), jmxBean)) {
75
43aa4625ab7e throw ConfigurationException instead of returning null, if database or formatter of given name is not configured
František Kučera <franta-hg@frantovo.cz>
parents: 70
diff changeset
   160
			log.log(Level.FINE, "Database connected");
104
245f1b88a3e6 formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents: 101
diff changeset
   161
			try (Formatter f = fd.getInstance(new FormatterContext(options.getOutputStream(), options.getFormatterProperties()))) {
101
97b0d9069133 Formatter is now AutoCloseable – so have chance to do some clean up and close the stream, if some error occurs (e.g. lost connection during result set reading)
František Kučera <franta-hg@frantovo.cz>
parents: 96
diff changeset
   162
				c.executeQuery(options.getSQLCommand(), f);
97b0d9069133 Formatter is now AutoCloseable – so have chance to do some clean up and close the stream, if some error occurs (e.g. lost connection during result set reading)
František Kučera <franta-hg@frantovo.cz>
parents: 96
diff changeset
   163
			}
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   164
		}
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   165
	}
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   166
144
d273d7c6dc0c Batch: basic encoder and prepare batch
František Kučera <franta-hg@frantovo.cz>
parents: 106
diff changeset
   167
	private void processPrepareBatch() throws BatchException {
d273d7c6dc0c Batch: basic encoder and prepare batch
František Kučera <franta-hg@frantovo.cz>
parents: 106
diff changeset
   168
		BatchEncoder enc = new BatchEncoder();
d273d7c6dc0c Batch: basic encoder and prepare batch
František Kučera <franta-hg@frantovo.cz>
parents: 106
diff changeset
   169
		int length = enc.encode(options.getSQLCommand(), options.getOutputStream());
d273d7c6dc0c Batch: basic encoder and prepare batch
František Kučera <franta-hg@frantovo.cz>
parents: 106
diff changeset
   170
		log.log(Level.FINE, "Prepared batch size: {0} bytes", length);
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   171
	}
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   172
146
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
   173
	private void processExecuteBatch() throws ConfigurationException, SQLException, FormatterException, BatchException {
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
   174
		BatchDecoder dec = new BatchDecoder();
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
   175
		Batch b = dec.decode(options.getInputStream());
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
   176
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
   177
		DatabaseDefinition dd = getConfiguration().getDatabase(options.getDatabaseName());
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
   178
		FormatterDefinition fd = configuration.getFormatter(options.getFormatterName());
179
236332caeb29 Basic JMX management/reporting – counters for commands and records
František Kučera <franta-hg@frantovo.cz>
parents: 166
diff changeset
   179
		ConnectionManagement jmxBean = ManagementUtils.registerMBean(dd.getName());
236332caeb29 Basic JMX management/reporting – counters for commands and records
František Kučera <franta-hg@frantovo.cz>
parents: 166
diff changeset
   180
236332caeb29 Basic JMX management/reporting – counters for commands and records
František Kučera <franta-hg@frantovo.cz>
parents: 166
diff changeset
   181
		try (DatabaseConnection c = dd.connect(options.getDatabaseProperties(), jmxBean)) {
146
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
   182
			log.log(Level.FINE, "Database connected");
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
   183
			try (Formatter f = fd.getInstance(new FormatterContext(options.getOutputStream(), options.getFormatterProperties()))) {
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
   184
				c.executeBatch(b, f);
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
   185
			}
4f4f515df807 BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents: 144
diff changeset
   186
		}
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   187
	}
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   188
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   189
	@Override
33
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   190
	public Configuration getConfiguration() throws ConfigurationException {
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   191
		if (configuration == null) {
189
f4d879cbcee1 separate configuration loading into the Loader class
František Kučera <franta-hg@frantovo.cz>
parents: 179
diff changeset
   192
			configuration = configurationLoader.loadConfiguration();
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   193
		}
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   194
		return configuration;
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   195
	}
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   196
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   197
	private void installDefaultConfiguration() throws ConfigurationException {
33
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   198
		Constants.DIR.mkdir();
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   199
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   200
		if (Constants.CONFIG_FILE.exists()) {
55
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents: 48
diff changeset
   201
			log.log(Level.FINER, "Config file already exists: {0}", Constants.CONFIG_FILE);
33
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   202
		} else {
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   203
			try {
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   204
				Functions.installResource(Constants.EXAMPLE_CONFIG_FILE, Constants.CONFIG_FILE);
55
f5ed7c4efacc colorful logging
František Kučera <franta-hg@frantovo.cz>
parents: 48
diff changeset
   205
				log.log(Level.FINE, "Installing default config file: {0}", Constants.CONFIG_FILE);
33
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   206
			} catch (IOException e) {
34
9335cf31c0f2 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 33
diff changeset
   207
				throw new ConfigurationException("Unable to write example configuration to " + Constants.CONFIG_FILE, e);
33
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   208
			}
04db6ccd6c48 configuration loading from XML
František Kučera <franta-hg@frantovo.cz>
parents: 26
diff changeset
   209
		}
20
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   210
	}
e225bdcd260e refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   211
80
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   212
	private void generateBashCompletion() {
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   213
		if (configuration == null) {
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   214
			log.log(Level.FINER, "Not writing Bash completion helper files. In order to generate these files please run some command which requires configuration.");
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   215
		} else {
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   216
			try {
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   217
				File dir = new File(Constants.DIR, "bash-completion");
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   218
				dir.mkdir();
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   219
				writeBashCompletionHelperFile(configuration.getDatabases(), new File(dir, "databases"));
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   220
				writeBashCompletionHelperFile(configuration.getAllFormatters(), new File(dir, "formatters"));
220
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   221
				writeBashCompletionHelperFileForFormatterProperties(new File(dir, "formatter-properties"));
80
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   222
			} catch (Exception e) {
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   223
				log.log(Level.WARNING, "Unable to generate Bash completion helper files", e);
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   224
			}
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   225
		}
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   226
	}
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   227
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   228
	private void writeBashCompletionHelperFile(Collection<? extends NameIdentified> items, File target) throws FileNotFoundException {
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   229
		if (Constants.CONFIG_FILE.lastModified() > target.lastModified()) {
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   230
			try (PrintWriter fw = new PrintWriter(target)) {
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   231
				for (NameIdentified dd : items) {
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   232
					fw.println(dd.getName());
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   233
				}
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   234
				fw.close();
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   235
				log.log(Level.FINE, "Bash completion helper file was written: {0}", target);
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   236
			}
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   237
		} else {
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   238
			log.log(Level.FINER, "Not writing Bash completion helper file: {0} because configuration {1} has not been changed", new Object[]{target, Constants.CONFIG_FILE});
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   239
		}
c4635ab3a7af bash completion: generate helper files with databases and formatters from configuration
František Kučera <franta-hg@frantovo.cz>
parents: 75
diff changeset
   240
	}
220
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   241
221
e38910065d55 bash-completion: --formatter-property choices: first working version
František Kučera <franta-hg@frantovo.cz>
parents: 220
diff changeset
   242
	private void writeBashCompletionHelperFileForFormatterProperties(File formattersDir) throws ClassNotFoundException, FileNotFoundException {
220
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   243
		if (Constants.CONFIG_FILE.lastModified() > formattersDir.lastModified()) {
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   244
			// TODO: delete old directory
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   245
			formattersDir.mkdir();
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   246
			for (FormatterDefinition fd : configuration.getAllFormatters()) {
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   247
				File formatterDir = new File(formattersDir, fd.getName());
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   248
				formatterDir.mkdir();
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   249
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   250
				Class<Formatter> formatterClass = (Class<Formatter>) Class.forName(fd.getClassName());
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   251
				List<Class<? extends Formatter>> hierarchy = Functions.getClassHierarchy(formatterClass, Formatter.class);
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   252
				Collections.reverse(hierarchy);
221
e38910065d55 bash-completion: --formatter-property choices: first working version
František Kučera <franta-hg@frantovo.cz>
parents: 220
diff changeset
   253
				for (Class<? extends Formatter> c : hierarchy) {
220
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   254
					for (PropertyDeclaration p : Functions.getPropertyDeclarations(c)) {
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   255
						File propertyDir = new File(formatterDir, p.name());
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   256
						propertyDir.mkdir();
221
e38910065d55 bash-completion: --formatter-property choices: first working version
František Kučera <franta-hg@frantovo.cz>
parents: 220
diff changeset
   257
						File choicesFile = new File(propertyDir, "choices");
e38910065d55 bash-completion: --formatter-property choices: first working version
František Kučera <franta-hg@frantovo.cz>
parents: 220
diff changeset
   258
						try (PrintWriter fw = new PrintWriter(choicesFile)) {
e38910065d55 bash-completion: --formatter-property choices: first working version
František Kučera <franta-hg@frantovo.cz>
parents: 220
diff changeset
   259
							// TODO: refactor, move
e38910065d55 bash-completion: --formatter-property choices: first working version
František Kučera <franta-hg@frantovo.cz>
parents: 220
diff changeset
   260
							if (p.type() == Boolean.class) {
e38910065d55 bash-completion: --formatter-property choices: first working version
František Kučera <franta-hg@frantovo.cz>
parents: 220
diff changeset
   261
								fw.println("true");
e38910065d55 bash-completion: --formatter-property choices: first working version
František Kučera <franta-hg@frantovo.cz>
parents: 220
diff changeset
   262
								fw.println("false");
e38910065d55 bash-completion: --formatter-property choices: first working version
František Kučera <franta-hg@frantovo.cz>
parents: 220
diff changeset
   263
							}
e38910065d55 bash-completion: --formatter-property choices: first working version
František Kučera <franta-hg@frantovo.cz>
parents: 220
diff changeset
   264
						}
220
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   265
					}
221
e38910065d55 bash-completion: --formatter-property choices: first working version
František Kučera <franta-hg@frantovo.cz>
parents: 220
diff changeset
   266
				}
220
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   267
			}
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   268
			log.log(Level.FINE, "Bash completion helper files was written in: {0}", formattersDir);
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   269
		} else {
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   270
			log.log(Level.FINER, "Not writing Bash completion helper directory: {0} because configuration {1} has not been changed", new Object[]{formattersDir, Constants.CONFIG_FILE});
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   271
		}
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   272
0bc544b38cfa bash-completion: --formatter-property names
František Kučera <franta-hg@frantovo.cz>
parents: 189
diff changeset
   273
	}
1
f32dac78d13a WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   274
}