Skip to content

Commit

Permalink
Merge pull request #129 from serge-pouliquen-itf:master
Browse files Browse the repository at this point in the history
  • Loading branch information
avbasov committed Mar 28, 2016
2 parents 2889f9d + 01e3e03 commit 96d2377
Show file tree
Hide file tree
Showing 36 changed files with 2,885 additions and 184 deletions.
42 changes: 34 additions & 8 deletions src/main/java/cz/startnet/utils/pgdiff/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@
*/
package cz.startnet.utils.pgdiff;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

/**
* Compares two PostgreSQL dumps and outputs information about differences in
* the database schemas.
*
*
* @author fordfrog
*/
public class Main {

/**
* APgDiff main method.
*
* @param args the command line arguments
*
* @throws UnsupportedEncodingException Thrown if unsupported output
* encoding has been encountered.
*
* @param args
* the command line arguments
*
* @throws UnsupportedEncodingException
* Thrown if unsupported output encoding has been encountered.
*/
public static void main(final String[] args)
throws UnsupportedEncodingException {
Expand All @@ -32,15 +34,39 @@ public static void main(final String[] args)
final PgDiffArguments arguments = new PgDiffArguments();

if (arguments.parse(writer, args)) {
// localvar in case of print
@SuppressWarnings("UseOfSystemOutOrSystemErr")
final PrintWriter encodedWriter = new PrintWriter(
new OutputStreamWriter(
System.out, arguments.getOutCharsetName()));
new OutputStreamWriter(System.out,
arguments.getOutCharsetName()) {
@Override
public void write(int c) throws IOException {
PgDiff.hasPrint = true;
super.write(c);
}

@Override
public void write(char cbuf[], int off, int len)
throws IOException {
PgDiff.hasPrint = true;
super.write(cbuf, off, len);
}

@Override
public void write(String str, int off, int len)
throws IOException {
PgDiff.hasPrint = true;
super.write(str, off, len);
}
});
PgDiff.createDiff(encodedWriter, arguments);
encodedWriter.close();
}

writer.close();
if (PgDiff.isDifferent) {
System.exit(1);
}
}

/**
Expand Down
Loading

0 comments on commit 96d2377

Please sign in to comment.