package com.github.cstroe.svndumpgui.internal.utility;


import com.github.cstroe.svndumpgui.api.SvnDumpWriter;
import com.github.cstroe.svndumpgui.generated.ParseException;
import com.github.cstroe.svndumpgui.generated.SvnDumpFileParser;
import com.github.cstroe.svndumpgui.generated.TokenMgrError;
import com.github.cstroe.svndumpgui.internal.writer.SvnDumpSummary;

import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

//import com.github.cstroe.svndumpgui.internal.writer.SvnDumpDebug;

/**
 * Use this from a command line interface to pipe your dump into svndumpgui,
 * and optionally out to something else.
 *
 * Add your SvnDumpConsumers to the chain to achieve the desired output.
 */
public class PipeThrough {

    public static void main(final String[] args) throws ParseException, UnsupportedEncodingException, FileNotFoundException {
        SvnDumpWriter writer = new SvnDumpSummary();
        writer.writeTo(System.out);
        //new SvnDumpDebug().after(writer);

        //InputStream is = new BufferedInputStream(new FileInputStream("/home/cosmin/Zoo/svndumpgui/svndump"));
        FastCharStream fastCharStream = new FastCharStream(new InputStreamReader(System.in, "US-ASCII"));
        SvnDumpFileParser parser = new SvnDumpFileParser(fastCharStream);
        //parser.setFileContentChunkSize(1024 * 1024 * 32);
        try {
            parser.Start(writer);
        } catch(TokenMgrError err) {
            System.err.println(err.getMessage());
            System.err.println("Stream position: " + fastCharStream.getStreamPosition());
        }

        System.out.flush();
    }
}

@@ -236,69 +236,8 @@
 er;%0A
-import com.github.cstroe.svndumpgui.generated.TokenMgrError;%0A
 impo
@@ -300,16 +300,16 @@
 ummary;%0A
+
 %0Aimport 
@@ -343,42 +343,8 @@
 on;%0A
-import java.io.InputStreamReader;%0A
 impo
@@ -389,77 +389,8 @@
 n;%0A%0A
-//import com.github.cstroe.svndumpgui.internal.writer.SvnDumpDebug;%0A%0A
 /**%0A
@@ -842,632 +842,53 @@
     
-//new SvnDumpDebug().after(writer);%0A%0A        //InputStream is = new BufferedInputStream(new FileInputStream(%22/home/cosmin/Zoo/svndumpgui/svndump%22));%0A        FastCharStream fastCharStream = new FastCharStream(new InputStreamReader(System.in, %22US-ASCII%22));%0A        SvnDumpFileParser parser = new SvnDumpFileParser(fastCharStream);%0A        //parser.setFileContentChunkSize(1024 * 1024 * 32);%0A        try %7B%0A            parser.Start(writer);%0A        %7D catch(TokenMgrError err) %7B%0A            System.err.println(err.getMessage());%0A            System.err.println(%22Stream position: %22 + fastCharStream.getStreamPosition());%0A        %7D%0A
+SvnDumpFileParser.consume(System.in, writer);
 %0A   

Clean up the mess.