mirror of
https://github.com/irongut/CodeCoverageSummary.git
synced 2026-05-19 16:30:14 +02:00
added args using CommandLineParser
This commit is contained in:
@@ -5,4 +5,8 @@
|
|||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="CommandLineParser" Version="2.8.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using CommandLine;
|
||||||
|
|
||||||
|
namespace CodeCoverageSummary
|
||||||
|
{
|
||||||
|
public class CommandLineOptions
|
||||||
|
{
|
||||||
|
[Value(index: 0, Required = true, HelpText = "Code coverage file to analyse.")]
|
||||||
|
public string Filename { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using CommandLine;
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -8,21 +9,33 @@ namespace CodeCoverageSummary
|
|||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
private const string _filename = "D:\\Dev\\Csharp\\CodeCoverageSummary\\coverage.cobertura.xml";
|
//private const string _filename = "D:\\Dev\\Csharp\\CodeCoverageSummary\\coverage.cobertura.xml";
|
||||||
|
|
||||||
private static int Main(string[] args)
|
private static int Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Parsing Code Coverage File: {_filename}{Environment.NewLine}");
|
return Parser.Default.ParseArguments<CommandLineOptions>(args)
|
||||||
string summary = ParseTestResults(_filename);
|
.MapResult<CommandLineOptions, int>(o =>
|
||||||
if (string.IsNullOrWhiteSpace(summary))
|
{
|
||||||
{
|
try
|
||||||
return -3;
|
{
|
||||||
}
|
Console.WriteLine($"Parsing Code Coverage File: {o.Filename}{Environment.NewLine}");
|
||||||
else
|
string summary = ParseTestResults(o.Filename);
|
||||||
{
|
if (string.IsNullOrWhiteSpace(summary))
|
||||||
Console.WriteLine(summary);
|
{
|
||||||
return 0;
|
return -2; // error
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine(summary);
|
||||||
|
return 0; // success
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return -3; // unhandled error
|
||||||
|
}
|
||||||
|
},
|
||||||
|
errs => -1); // invalid arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ParseTestResults(string filename)
|
private static string ParseTestResults(string filename)
|
||||||
|
|||||||
Reference in New Issue
Block a user