mirror of
https://github.com/irongut/CodeCoverageSummary.git
synced 2026-05-15 14:40:13 +02:00
added output type arg
This commit is contained in:
@@ -12,5 +12,8 @@ namespace CodeCoverageSummary
|
||||
|
||||
[Option(shortName: 'b', longName: "badge", Required = false, HelpText = "Include a badge in the output - true / false (default).", Default = false)]
|
||||
public bool Badge { get; set; }
|
||||
|
||||
[Option(shortName: 'o', longName: "output", Required = false, HelpText = "Output Type - console (default), file or both.", Default = "console")]
|
||||
public string Output { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,9 +47,10 @@ namespace CodeCoverageSummary
|
||||
}
|
||||
|
||||
StringBuilder summaryText = new();
|
||||
string fileExt = "txt";
|
||||
if (o.Format.Equals("text", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(badgeUrl))
|
||||
if (!string.IsNullOrWhiteSpace(badgeUrl))
|
||||
{
|
||||
summaryText.AppendLine(badgeUrl);
|
||||
}
|
||||
@@ -65,6 +66,8 @@ namespace CodeCoverageSummary
|
||||
}
|
||||
else if (o.Format.Equals("md", StringComparison.OrdinalIgnoreCase) || o.Format.Equals("markdown", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
fileExt = "md";
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(badgeUrl))
|
||||
{
|
||||
summaryText.AppendLine($"");
|
||||
@@ -87,7 +90,16 @@ namespace CodeCoverageSummary
|
||||
return -2; // error
|
||||
}
|
||||
|
||||
Console.WriteLine(summaryText.ToString());
|
||||
if (o.Output.Equals("console", StringComparison.OrdinalIgnoreCase) || o.Output.Equals("both", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Console.WriteLine(summaryText.ToString());
|
||||
}
|
||||
|
||||
if (o.Output.Equals("file", StringComparison.OrdinalIgnoreCase) || o.Output.Equals("both", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
File.WriteAllText($"code-coverage-results.{fileExt}", summaryText.ToString());
|
||||
}
|
||||
|
||||
return 0; // success
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user