<commit_before>package;


import lime.tools.helpers.LogHelper;
import lime.tools.helpers.PathHelper;
import lime.tools.helpers.ProcessHelper;
import lime.project.Haxelib;
import sys.FileSystem;


class RunScript {
	
	
	/*static private function buildDocumentation ():Void {
		
		var openFLDirectory = PathHelper.getHaxelib (new Haxelib ("openfl"), true);
		var scriptPath = PathHelper.combine (openFLDirectory, "script");
		var documentationPath = PathHelper.combine (openFLDirectory, "documentation");
		
		PathHelper.mkdir (documentationPath);
		
		runCommand (scriptPath, "haxe", [ "documentation.hxml" ]);
		
		FileHelper.copyFile (PathHelper.combine (openFLDirectory, "haxedoc.xml"), documentationPath + "/openfl.xml");
		
		runCommand (documentationPath, "haxedoc", [ "openfl.xml", "-f", "openfl", "-f", "flash" ]);
		
	}*/
	
	
	public static function main () {
		
		var args = Sys.args ();
		var workingDirectory = args.pop ();
		
		if (args.length > 1 && args[0] == "create") {
			
			//args[1] = "openfl:" + args[1];
			
		} else if (args.length > 0 && args[0] == "setup") {
			
			var limeDirectory = PathHelper.getHaxelib (new Haxelib ("lime"));
			
			if (limeDirectory == null || limeDirectory == "" || limeDirectory.indexOf ("is not installed") > -1) {
				
				Sys.command ("haxelib", [ "install", "lime" ]);
				
			}
			
		} else if (args.length > 0 && args[0] == "process") {
			
			if (!FileSystem.exists ("tools/tools.n")) {
				
				rebuildTools ();
				
			}
			
			Sys.exit (Sys.command ("neko", [ "tools/tools.n" ].concat (Sys.args ())));
			return;
			
		}
		
		var args = [ "run", "lime" ].concat (args);
		
		try {
			
			Sys.setCwd (workingDirectory);
			
		} catch (e:Dynamic) {
			
			LogHelper.error ("Cannot set current working directory to \"" + workingDirectory + "\"");
			
		}
		
		Sys.exit (Sys.command ("haxelib", args.concat ([ "-openfl" ])));
		
	}
	
	
	private static function rebuildTools (rebuildBinaries = true):Void {
		
		var openflDirectory = PathHelper.getHaxelib (new Haxelib ("openfl"), true);
		var toolsDirectory = PathHelper.combine (openflDirectory, "tools");
		
		ProcessHelper.runCommand (toolsDirectory, "haxe", [ "tools.hxml" ]);
		
	}
	
	
}<commit_msg>Minor run script fix<commit_after>package;


import lime.tools.helpers.LogHelper;
import lime.tools.helpers.PathHelper;
import lime.tools.helpers.ProcessHelper;
import lime.project.Haxelib;
import sys.FileSystem;


class RunScript {
	
	
	/*static private function buildDocumentation ():Void {
		
		var openFLDirectory = PathHelper.getHaxelib (new Haxelib ("openfl"), true);
		var scriptPath = PathHelper.combine (openFLDirectory, "script");
		var documentationPath = PathHelper.combine (openFLDirectory, "documentation");
		
		PathHelper.mkdir (documentationPath);
		
		runCommand (scriptPath, "haxe", [ "documentation.hxml" ]);
		
		FileHelper.copyFile (PathHelper.combine (openFLDirectory, "haxedoc.xml"), documentationPath + "/openfl.xml");
		
		runCommand (documentationPath, "haxedoc", [ "openfl.xml", "-f", "openfl", "-f", "flash" ]);
		
	}*/
	
	
	public static function main () {
		
		var args = Sys.args ();
		var cacheDirectory = Sys.getCwd ();
		var workingDirectory = args.pop ();
		
		try {
			
			Sys.setCwd (workingDirectory);
			
		} catch (e:Dynamic) {
			
			LogHelper.error ("Cannot set current working directory to \"" + workingDirectory + "\"");
			
		}
		
		if (args.length > 1 && args[0] == "create") {
			
			//args[1] = "openfl:" + args[1];
			
		} else if (args.length > 0 && args[0] == "setup") {
			
			var limeDirectory = PathHelper.getHaxelib (new Haxelib ("lime"));
			
			if (limeDirectory == null || limeDirectory == "" || limeDirectory.indexOf ("is not installed") > -1) {
				
				Sys.command ("haxelib", [ "install", "lime" ]);
				
			}
			
		} else if (args.length > 0 && args[0] == "process") {
			
			Sys.setCwd (cacheDirectory);
			
			if (!FileSystem.exists ("tools/tools.n")) {
				
				rebuildTools ();
				
			}
			
			Sys.exit (Sys.command ("neko", [ "tools/tools.n" ].concat (Sys.args ())));
			return;
			
		}
		
		var args = [ "run", "lime" ].concat (args);
		Sys.exit (Sys.command ("haxelib", args.concat ([ "-openfl" ])));
		
	}
	
	
	private static function rebuildTools (rebuildBinaries = true):Void {
		
		var openflDirectory = PathHelper.getHaxelib (new Haxelib ("openfl"), true);
		var toolsDirectory = PathHelper.combine (openflDirectory, "tools");
		
		ProcessHelper.runCommand (toolsDirectory, "haxe", [ "tools.hxml" ]);
		
	}
	
	
}
{'fraction_non_alphanumeric': 0.16155555555555556, 'fraction_numerical': 0.004, 'mean_word_length': 3.3320500481231954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5173249', 'n_tokens_mistral': 1800, 'n_tokens_neox': 1443, 'n_words': 332}