5
5
*/
6
6
package cz .startnet .utils .pgdiff ;
7
7
8
+ import java .io .IOException ;
8
9
import java .io .OutputStreamWriter ;
9
10
import java .io .PrintWriter ;
10
11
import java .io .UnsupportedEncodingException ;
11
12
12
13
/**
13
14
* Compares two PostgreSQL dumps and outputs information about differences in
14
15
* the database schemas.
15
- *
16
+ *
16
17
* @author fordfrog
17
18
*/
18
19
public class Main {
19
20
20
21
/**
21
22
* APgDiff main method.
22
- *
23
- * @param args the command line arguments
24
- *
25
- * @throws UnsupportedEncodingException Thrown if unsupported output
26
- * encoding has been encountered.
23
+ *
24
+ * @param args
25
+ * the command line arguments
26
+ *
27
+ * @throws UnsupportedEncodingException
28
+ * Thrown if unsupported output encoding has been encountered.
27
29
*/
28
30
public static void main (final String [] args )
29
31
throws UnsupportedEncodingException {
@@ -32,15 +34,39 @@ public static void main(final String[] args)
32
34
final PgDiffArguments arguments = new PgDiffArguments ();
33
35
34
36
if (arguments .parse (writer , args )) {
37
+ // localvar in case of print
35
38
@ SuppressWarnings ("UseOfSystemOutOrSystemErr" )
36
39
final PrintWriter encodedWriter = new PrintWriter (
37
- new OutputStreamWriter (
38
- System .out , arguments .getOutCharsetName ()));
40
+ new OutputStreamWriter (System .out ,
41
+ arguments .getOutCharsetName ()) {
42
+ @ Override
43
+ public void write (int c ) throws IOException {
44
+ PgDiff .hasPrint = true ;
45
+ super .write (c );
46
+ }
47
+
48
+ @ Override
49
+ public void write (char cbuf [], int off , int len )
50
+ throws IOException {
51
+ PgDiff .hasPrint = true ;
52
+ super .write (cbuf , off , len );
53
+ }
54
+
55
+ @ Override
56
+ public void write (String str , int off , int len )
57
+ throws IOException {
58
+ PgDiff .hasPrint = true ;
59
+ super .write (str , off , len );
60
+ }
61
+ });
39
62
PgDiff .createDiff (encodedWriter , arguments );
40
63
encodedWriter .close ();
41
64
}
42
65
43
66
writer .close ();
67
+ if (PgDiff .isDifferent ) {
68
+ System .exit (1 );
69
+ }
44
70
}
45
71
46
72
/**
0 commit comments