public static void Write(Result result, CLICommandOptions options) { CommandResultsWriter?writer = WriterFactory.GetWriter(options); string commandCompletedMsg; //perform type checking and assign final msg string if (result is TagTestResult) { commandCompletedMsg = "Tag Test"; } else if (result is TagDiffResult) { commandCompletedMsg = "Tag Diff"; } else if (result is ExportTagsResult) { commandCompletedMsg = "Export Tags"; } else if (result is VerifyRulesResult) { commandCompletedMsg = "Verify Rules"; } else if (result is PackRulesResult) { commandCompletedMsg = "Pack Rules"; } else if (result is AnalyzeResult analyzeResult && options is CLIAnalyzeCmdOptions cLIAnalyzeCmdOptions) //special handling for html format { commandCompletedMsg = "Analyze"; //additional prechecks required for analyze html format if (cLIAnalyzeCmdOptions.OutputFileFormat == "html") { int MAX_HTML_REPORT_FILE_SIZE = 1024 * 1000 * 3; //warn about potential slow rendering //prechecks if (analyzeResult.ResultCode != AnalyzeResult.ExitCode.Success) { Finalize(writer, commandCompletedMsg); return; } writer?.WriteResults(analyzeResult, cLIAnalyzeCmdOptions); //post checks if (File.Exists(options.OutputFilePath) && new FileInfo(options.OutputFilePath).Length > MAX_HTML_REPORT_FILE_SIZE) { WriteOnce.Info(MsgHelp.GetString(MsgHelp.ID.ANALYZE_REPORTSIZE_WARN)); } if (!cLIAnalyzeCmdOptions.SuppressBrowserOpen) { Utils.OpenBrowser(cLIAnalyzeCmdOptions.OutputFilePath); } Finalize(writer, "Analyze"); return; } }
private void WriteJsonResult() { //writes out json report for convenient link from report summary page(s) CLIAnalyzeCmdOptions jsonOptions = new CLIAnalyzeCmdOptions() { OutputFileFormat = "json", OutputFilePath = "output.json" }; //quiet normal write noise for json writter to just gen the file; then restore WriteOnce.ConsoleVerbosity saveVerbosity = WriteOnce.Verbosity; WriteOnce.Verbosity = WriteOnce.ConsoleVerbosity.None; AnalyzeJsonWriter jsonWriter = (AnalyzeJsonWriter)WriterFactory.GetWriter(jsonOptions); jsonWriter.WriteResults(_analyzeResult, jsonOptions); WriteOnce.Verbosity = saveVerbosity; }