public static void __Main(string[] args, bool throwException = false) { CoffeeScriptRunTime cs = new CoffeeScriptRunTime(); if (args.Length == 0) { cs.DisplayLogo(true); Console.WriteLine(@" How to execute a coffee script file CoffeeScriptRunTime.exe myfile.coffee How to create the corresponding javascript file from a coffee script file CoffeeScriptRunTime.exe myfile.coffee -compile How to execute a javascript script file CoffeeScriptRunTime.exe myfile.js How to compile a javascript script file with Google Closure Compiler CoffeeScriptRunTime.exe myfile.js -compile Others options: -pause: Wait for an enter key at the end -nologo: Do do not display the logo -displayJavacript: -Display the JavaScript source created (CoffeeScript only) "); } var displayLogo = !args.Contains("-nologo"); var pause = args.Contains("-pause"); var displayJavaScriptCode = args.Contains("-displayJavacript"); var action = args.Contains("-compile") ? Action.Compile : Action.Run; cs.DisplayLogo(displayLogo); foreach (var p in args) { if ((!p.StartsWith("-")) && (System.IO.File.Exists(p))) { if (System.IO.Path.GetExtension(p) == ".coffee") { var status = cs.CompileAndOrRunCoffeeScript(p, action, displayJavaScriptCode); if (throwException && !status.Succeeded) { throw new ApplicationException(status.ToString()); } } else if (System.IO.Path.GetExtension(p) == ".js") { if (action == Action.Run) { cs.RunJavaScript(p); } else if (action == Action.Compile) { ClosureCompiler closure = new ClosureCompiler(); var status = closure.Compile(p); if (throwException && !status.Succeeded) { throw new ApplicationException(status.ToString()); } } } } } if (pause) { Console.WriteLine("Hit enter to continue"); Console.ReadLine(); } }
public static void __Main(string[] args, bool throwException = false) { CoffeeScriptRunTime cs = new CoffeeScriptRunTime(); if(args.Length==0){ cs.DisplayLogo(true); Console.WriteLine(@" How to execute a coffee script file CoffeeScriptRunTime.exe myfile.coffee How to create the corresponding javascript file from a coffee script file CoffeeScriptRunTime.exe myfile.coffee -compile How to execute a javascript script file CoffeeScriptRunTime.exe myfile.js How to compile a javascript script file with Google Closure Compiler CoffeeScriptRunTime.exe myfile.js -compile Others options: -pause: Wait for an enter key at the end -nologo: Do do not display the logo -displayJavacript: -Display the JavaScript source created (CoffeeScript only) "); } var displayLogo = !args.Contains("-nologo"); var pause = args.Contains("-pause"); var displayJavaScriptCode = args.Contains("-displayJavacript"); var action = args.Contains("-compile") ? Action.Compile : Action.Run; cs.DisplayLogo(displayLogo); foreach(var p in args){ if((!p.StartsWith("-"))&&(System.IO.File.Exists(p))){ if(System.IO.Path.GetExtension(p)==".coffee"){ var status = cs.CompileAndOrRunCoffeeScript(p, action, displayJavaScriptCode); if (throwException && !status.Succeeded) throw new ApplicationException(status.ToString()); } else if(System.IO.Path.GetExtension(p)==".js"){ if(action==Action.Run){ cs.RunJavaScript(p); } else if(action== Action.Compile) { ClosureCompiler closure = new ClosureCompiler(); var status = closure.Compile(p); if (throwException && !status.Succeeded) throw new ApplicationException(status.ToString()); } } } } if(pause){ Console.WriteLine("Hit enter to continue"); Console.ReadLine(); } }