/// <summary> /// The command line program entry point. /// </summary> /// <param name="args"> /// Command line arguments. /// </param> public static void Main(string[] args) { try { var commandLineArguments = new CommandLineArguments(args, new CompilationLevelHelper()); if (!commandLineArguments.AreValid) { return; } const string CompilerUrl = @"http://closure-compiler.appspot.com/compile"; XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config")); var requestCompile = new RequestCompile( commandLineArguments.FileName, commandLineArguments.CompilationLevel, CompilerUrl, commandLineArguments.SuppressedWarnings); requestCompile.Run(); } catch (Exception e) { Log.Info("An Error Occurred Running GoogleCC:"); Log.Info(e.Message); Log.Info(e.StackTrace); } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { var dte = Package.GetGlobalService(typeof(DTE)) as DTE; var doc = dte.ActiveDocument; if (doc == null) { MessageBox.Show("Please open a JavaScript file", "JS Google Closure Compiler"); return; } errorListHelper.Remove(); const string CompilerUrl = @"http://closure-compiler.appspot.com/compile"; var requestCompile = new RequestCompile( doc.FullName, CompilationLevelHelper.AdvancedOptimizations, CompilerUrl); Action asyncRunner = () => { var compilerResults = requestCompile.Run(); var resultsWriter = new ResultsWriter(errorListHelper); resultsWriter.EmitErrors(compilerResults); resultsWriter.EmitWarnings(compilerResults); }; var task1 = new System.Threading.Tasks.Task(asyncRunner); task1.Start(); }