public int Run() { model = new Diags.Model(null); int exitCode = ParseArgs(); if (exitCode == 0) { if (model.Data.Scope == Granularity.Detail) { NotifyEvery = 0; } if (mirrorName != null) { try { var mirrorWriter = new TextWriterTraceListener(mirrorName); mirrorWriter.WriteLine(String.Empty); mirrorWriter.WriteLine(Diags.MajorSeparator); mirrorWriter.WriteLine(DateTime.Now); Trace.Listeners.Add(mirrorWriter); } catch (Exception) { Console.Error.WriteLine("Ignoring malformed <mirror>"); } } if (model.Data.Scope <= Granularity.Verbose) { if (model.Data.IsDigestForm) { Trace.Write("; "); } Trace.WriteLine($"{ProductText} v{VersionText}"); Trace.WriteLine(String.Empty); } viewFactory.Create(this, model.Data); exitCode = (int)Severity.NoIssue; string err = null; #if !DEBUG try { #endif foreach (FormatBase.Model fmtModel in model.CheckRoot()) { } model.ReportSummary("checked"); exitCode = (int)model.Data.Result; #if !DEBUG } catch (Exception ex) when(ex is IOException || ex is ArgumentException) { err = ex.Message; } #endif if (err != null) { exitCode = (int)Severity.Fatal; Console.Error.WriteLine("* Error: " + err); } } if (waitForKeyPress) { Console.WriteLine(); Console.Write("Press the escape key to escape..."); while (Console.ReadKey().Key != ConsoleKey.Escape) { } } return(exitCode); }
public int Run() { int exitCode = ParseArgs(args); if (exitCode == 0) { NotifyEvery = notifyEvery ?? (scope < Granularity.Verbose? 0 : 1); if (mirrorName != null) { try { var mirrorWriter = new TextWriterTraceListener(mirrorName); mirrorWriter.WriteLine(String.Empty); mirrorWriter.WriteLine(SessionSeparator); mirrorWriter.WriteLine(DateTime.Now); Trace.Listeners.Add(mirrorWriter); } catch (Exception) { Console.Error.WriteLine("Ignoring malformed <mirror>"); } } if (scope <= Granularity.Verbose) { Trace.WriteLine(ProductText + " v" + VersionText); Trace.WriteLine(String.Empty); } model = new Diags.Model(args[args.Length - 1], filter, exclusion, action, scope, warnEscalator, errEscalator); viewFactory.Create(this, model.Data); model.Data.HashFlags = hashes; model.Data.ValidationFlags = validations; exitCode = (int)Severity.NoIssue; string err = null; #if !DEBUG try { #endif foreach (FormatBase.Model fmtModel in model.CheckRoot()) { } model.Data.OnReportClose(); exitCode = (int)model.Data.Result; #if !DEBUG } catch (IOException ex) { err = ex.Message; } catch (ArgumentException ex) { err = ex.Message; } #endif if (err != null) { exitCode = (int)Severity.Fatal; Console.Error.WriteLine("* Error: " + err); } } if (waitForKeyPress) { Console.WriteLine(); Console.Write("Press the escape key to exit..."); while (Console.ReadKey().Key != ConsoleKey.Escape) { } } return(exitCode); }