Browse Source

- fixed temploc (bug related to haxe IntIter problems)
- added silent mode to avoid printing things in Loader

Laurent Bedubourg 19 years ago
parent
commit
4582819e69
2 changed files with 16 additions and 7 deletions
  1. 5 2
      std/mtwin/templo/Loader.hx
  2. 11 5
      std/mtwin/templo/Main.hx

+ 5 - 2
std/mtwin/templo/Loader.hx

@@ -64,10 +64,13 @@ class Loader {
 				return;
 				return;
 		}
 		}
 		var result = 0;
 		var result = 0;
+
+		var macroArg = if (MACROS == null) "" else "-m "+BASE_DIR+MACROS;
+
 		if (BASE_DIR == "")
 		if (BASE_DIR == "")
-			result = Sys.command("temploc -m "+BASE_DIR+MACROS+" -o "+TMP_DIR+" "+path+" 2> "+TMP_DIR+"temploc.out");
+			result = Sys.command("temploc -s "+macroArg+" -o "+TMP_DIR+" "+path+" 2> "+TMP_DIR+"temploc.out");
 		else
 		else
-			result = Sys.command("temploc -m "+BASE_DIR+MACROS+" -o "+TMP_DIR+" -r "+BASE_DIR+" "+path+" 2> "+TMP_DIR+"temploc.out");
+			result = Sys.command("temploc -s "+macroArg+" -o "+TMP_DIR+" -r "+BASE_DIR+" "+path+" 2> "+TMP_DIR+"temploc.out");
 		if( result != 0 )
 		if( result != 0 )
 			throw "temploc compilation or "+path+" failed : "+neko.io.File.getContent(Loader.TMP_DIR+"temploc.out");
 			throw "temploc compilation or "+path+" failed : "+neko.io.File.getContent(Loader.TMP_DIR+"temploc.out");
 	}
 	}

+ 11 - 5
std/mtwin/templo/Main.hx

@@ -30,16 +30,21 @@ class Main {
 	static var USAGE = "Usage: temploc -o </destination/dir> -m <macrofile.xml> -r </templates/repository> <files...>\n";
 	static var USAGE = "Usage: temploc -o </destination/dir> -m <macrofile.xml> -r </templates/repository> <files...>\n";
 	static var args : Array<String>;
 	static var args : Array<String>;
 	static var files : List<String>;
 	static var files : List<String>;
+	static var silence : Bool = false;
 
 
 	static function parseArgs(){
 	static function parseArgs(){
 		files = new List();
 		files = new List();
 		args = neko.Sys.args();
 		args = neko.Sys.args();
-		for (i in 0...args.length){
+		var i = 0;
+		while (i < args.length){
 			var arg = args[i];
 			var arg = args[i];
 			switch (arg){
 			switch (arg){
 				case "-h":
 				case "-h":
 					throw USAGE;
 					throw USAGE;
 
 
+				case "-s":
+					silence = true;
+
 				case "-r":
 				case "-r":
 					var value = args[i+1];
 					var value = args[i+1];
 					if (value.charAt(value.length-1) == "/"){
 					if (value.charAt(value.length-1) == "/"){
@@ -57,13 +62,13 @@ class Main {
 					++i;
 					++i;
 
 
 				case "-m":
 				case "-m":
-					var macroFile = args[i+1];
-					mtwin.templo.Preprocessor.registerMacroFile(macroFile);
+					mtwin.templo.Preprocessor.registerMacroFile(args[i+1]);
 					++i;
 					++i;
 
 
 				default:
 				default:
 					files.push(arg);
 					files.push(arg);
 			}
 			}
+			++i;
 		}
 		}
 		if (args.length == 0){
 		if (args.length == 0){
 			neko.Lib.print("temploc - v"+VERSION+"\n");
 			neko.Lib.print("temploc - v"+VERSION+"\n");
@@ -91,12 +96,13 @@ class Main {
 	}
 	}
 
 
 	static function main(){
 	static function main(){
+		Loader.MACROS = null;
 		parseArgs();
 		parseArgs();
 		for (file in files){
 		for (file in files){
 			file = StringTools.replace(file, Loader.BASE_DIR+"/", "");
 			file = StringTools.replace(file, Loader.BASE_DIR+"/", "");
-			neko.Lib.print("* "+file+"...");
+			if (!silence) neko.Lib.print("* "+file+"...");
 			mtwin.templo.Template.fromFile(file);
 			mtwin.templo.Template.fromFile(file);
-			neko.Lib.print(" done\n");
+			if (!silence) neko.Lib.print(" done\n");
 		}
 		}
 	}
 	}
 }
 }