Skip to content

Commit 96d2377

Browse files
committed
Merge pull request #129 from serge-pouliquen-itf:master
2 parents 2889f9d + 01e3e03 commit 96d2377

36 files changed

+2885
-184
lines changed

src/main/java/cz/startnet/utils/pgdiff/Main.java

+34-8
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@
55
*/
66
package cz.startnet.utils.pgdiff;
77

8+
import java.io.IOException;
89
import java.io.OutputStreamWriter;
910
import java.io.PrintWriter;
1011
import java.io.UnsupportedEncodingException;
1112

1213
/**
1314
* Compares two PostgreSQL dumps and outputs information about differences in
1415
* the database schemas.
15-
*
16+
*
1617
* @author fordfrog
1718
*/
1819
public class Main {
1920

2021
/**
2122
* 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.
2729
*/
2830
public static void main(final String[] args)
2931
throws UnsupportedEncodingException {
@@ -32,15 +34,39 @@ public static void main(final String[] args)
3234
final PgDiffArguments arguments = new PgDiffArguments();
3335

3436
if (arguments.parse(writer, args)) {
37+
// localvar in case of print
3538
@SuppressWarnings("UseOfSystemOutOrSystemErr")
3639
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+
});
3962
PgDiff.createDiff(encodedWriter, arguments);
4063
encodedWriter.close();
4164
}
4265

4366
writer.close();
67+
if (PgDiff.isDifferent) {
68+
System.exit(1);
69+
}
4470
}
4571

4672
/**

0 commit comments

Comments
 (0)