package com.conveyal.gtfs.validator.json;

import java.io.File;
import java.io.IOException;

import com.conveyal.gtfs.validator.json.backends.FileSystemFeedBackend;
import com.conveyal.gtfs.validator.json.serialization.JsonSerializer;

public class JsonValidatorMain {

	/**
	 * Take an input GTFS and an output file and write JSON to that output file summarizing validation of the GTFS.
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		if (args.length != 2) {
			System.err.println("usage: java -Xmx[several]G input_gtfs.zip output_file.json");
			return;
		}
		
		// We use a file system backend because we're not doing anything fancy, just reading local GTFS
		FileSystemFeedBackend backend = new FileSystemFeedBackend();
		File input = backend.getFeed(args[0]);
		FeedProcessor processor = new FeedProcessor(input);
		try {
			processor.run();
		} catch (IOException e) {
			e.printStackTrace();
			System.err.println("Unable to access input GTFS " + input.getPath() + ". Does the file exist and do I have permission to read it?");
			return;
		}
		FeedValidationResults out = processor.getOutput();
		JsonSerializer serializer = new JsonSerializer(out);
		// TODO: error handling
		serializer.serializeToFile(new File(args[1]));

	}

}

@@ -267,14 +267,20 @@
  %7B%0A%0A
-%09/**%0A%09
+    /**%0A    
  * T
@@ -387,17 +387,20 @@
 e GTFS.%0A
-%09
+    
  * @para
@@ -410,14 +410,20 @@
 rgs%0A
-%09 */%0A%09
+     */%0A    
 publ
@@ -476,18 +476,24 @@
 ption %7B%0A
-%09%09
+        
 if (args
@@ -504,19 +504,27 @@
 gth 
-!=
+%3C
  2) %7B%0A
-%09%09%09
+            
 Syst
@@ -585,48 +585,105 @@
 zip 
-output_file.json%22);%0A%09%09%09return;%0A%09%09%7D%0A%09%09%0A%09%09
+%5Bother_gtfs.zip third_gtfs.zip . . .%5D output_file.json%22);%0A            return;%0A        %7D%0A%0A        
 // W
@@ -774,18 +774,24 @@
 al GTFS%0A
-%09%09
+        
 FileSyst
@@ -843,18 +843,24 @@
 kend();%0A
-%09%09
+        
 File inp
@@ -890,18 +890,24 @@
 gs%5B0%5D);%0A
-%09%09
+        
 FeedProc
@@ -954,19 +954,34 @@
 t);%0A
-%09%09try %7B%0A%09%09%09
+        try %7B%0A            
 proc
@@ -993,18 +993,24 @@
 .run();%0A
-%09%09
+        
 %7D catch 
@@ -1027,19 +1027,28 @@
 on e) %7B%0A
-%09%09%09
+            
 e.printS
@@ -1060,19 +1060,28 @@
 race();%0A
-%09%09%09
+            
 System.e
@@ -1209,25 +1209,46 @@
 %22);%0A
-%09%09%09return;%0A%09%09%7D%0A%09%09
+            return;%0A        %7D%0A        
 Feed
@@ -1294,18 +1294,24 @@
 tput();%0A
-%09%09
+        
 JsonSeri
@@ -1355,18 +1355,24 @@
 r(out);%0A
-%09%09
+        
 // TODO:
@@ -1391,10 +1391,16 @@
 ing%0A
-%09%09
+        
 seri
@@ -1447,9 +1447,12 @@
 );%0A%0A
-%09
+    
 %7D%0A%0A%7D

fix indentation in JsonValidatorMain.