|
1 |
| -// Copyright (c) Toni Solarin-Sodara |
| 1 | +// Copyright (c) Toni Solarin-Sodara |
2 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
3 | 3 |
|
4 | 4 | using System;
|
@@ -30,31 +30,31 @@ public static class Program
|
30 | 30 | static int s_exitCode;
|
31 | 31 | static async Task Main(string[] args)
|
32 | 32 | {
|
33 |
| - CliArgument<string> moduleOrAppDirectory = new ("path") { Description = "Path to the test assembly or application directory." }; |
34 |
| - CliOption<string> target = new ("--target", aliases: new[]{ "--target", "-t" }) { Description = "Path to the test runner application." , Arity = ArgumentArity.ZeroOrOne, Required = true }; |
35 |
| - CliOption<string> targs = new ("--targetargs", aliases: new[] { "--targetargs", "-a" } ) { Description = "Arguments to be passed to the test runner.", Arity = ArgumentArity.ZeroOrOne }; |
36 |
| - CliOption<string> output = new ("--output", aliases: new[] { "--output", "-o" }) { Description = "Output of the generated coverage report", Arity = ArgumentArity.ZeroOrOne }; |
37 |
| - CliOption<LogLevel> verbosity = new ("--verbosity", aliases: new[] { "--verbosity", "-v" }) { DefaultValueFactory = (_) => LogLevel.Normal, Description = "Sets the verbosity level of the command. Allowed values are quiet, minimal, normal, detailed.", Arity = ArgumentArity.ZeroOrOne }; |
38 |
| - CliOption<string[]> formats = new ("--format", aliases: new[] { "--format", "-f" }) { DefaultValueFactory = (_) => new[] { "json" }, Description = "Format of the generated coverage report.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
39 |
| - CliOption<string> threshold = new ("--threshold") { Description = "Exits with error if the coverage % is below value.", Arity = ArgumentArity.ZeroOrOne }; |
40 |
| - CliOption<List<string>> thresholdTypes = new ("--threshold-type") { DefaultValueFactory = (_) => new List<string>(new string[] { "line", "branch", "method" }), Description = ("Coverage type to apply the threshold to.")}; |
| 33 | + Argument<string> moduleOrAppDirectory = new("path") { Description = "Path to the test assembly or application directory." }; |
| 34 | + Option<string> target = new("--target", aliases: new[] { "--target", "-t" }) { Description = "Path to the test runner application.", Arity = ArgumentArity.ZeroOrOne, Required = true }; |
| 35 | + Option<string> targs = new("--targetargs", aliases: new[] { "--targetargs", "-a" }) { Description = "Arguments to be passed to the test runner.", Arity = ArgumentArity.ZeroOrOne }; |
| 36 | + Option<string> output = new("--output", aliases: new[] { "--output", "-o" }) { Description = "Output of the generated coverage report", Arity = ArgumentArity.ZeroOrOne }; |
| 37 | + Option<LogLevel> verbosity = new("--verbosity", aliases: new[] { "--verbosity", "-v" }) { DefaultValueFactory = (_) => LogLevel.Normal, Description = "Sets the verbosity level of the command. Allowed values are quiet, minimal, normal, detailed.", Arity = ArgumentArity.ZeroOrOne }; |
| 38 | + Option<string[]> formats = new("--format", aliases: new[] { "--format", "-f" }) { DefaultValueFactory = (_) => new[] { "json" }, Description = "Format of the generated coverage report.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
| 39 | + Option<string> threshold = new("--threshold") { Description = "Exits with error if the coverage % is below value.", Arity = ArgumentArity.ZeroOrOne }; |
| 40 | + Option<List<string>> thresholdTypes = new("--threshold-type") { DefaultValueFactory = (_) => new List<string>(new string[] { "line", "branch", "method" }), Description = ("Coverage type to apply the threshold to.") }; |
41 | 41 | thresholdTypes.AcceptOnlyFromAmong("line", "branch", "method");
|
42 |
| - CliOption<ThresholdStatistic> thresholdStat = new ("--threshold-stat") {DefaultValueFactory = (_) => ThresholdStatistic.Minimum, Description = "Coverage statistic used to enforce the threshold value." , Arity = ArgumentArity.ZeroOrOne }; |
43 |
| - CliOption<string[]> excludeFilters = new ("--exclude") { Description = "Filter expressions to exclude specific modules and types.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
44 |
| - CliOption<string[]> includeFilters = new ("--include") { Description = "Filter expressions to include only specific modules and types.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
45 |
| - CliOption<string[]> excludedSourceFiles = new ("--exclude-by-file") { Description = "Glob patterns specifying source files to exclude.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
46 |
| - CliOption<string[]> includeDirectories = new("--include-directory") { Description = "Include directories containing additional assemblies to be instrumented.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
47 |
| - CliOption<string[]> excludeAttributes = new ("--exclude-by-attribute") { Description = "Attributes to exclude from code coverage.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
48 |
| - CliOption<bool> includeTestAssembly = new ("--include-test-assembly") { Description = "Specifies whether to report code coverage of the test assembly.", Arity = ArgumentArity.Zero }; |
49 |
| - CliOption<bool> singleHit = new ("--single-hit") { Description = "Specifies whether to limit code coverage hit reporting to a single hit for each location", Arity = ArgumentArity.Zero }; |
50 |
| - CliOption<bool> skipAutoProp = new ("--skipautoprops") { Description = "Neither track nor record auto-implemented properties.", Arity = ArgumentArity.Zero }; |
51 |
| - CliOption<string> mergeWith = new ("--merge-with") { Description = "Path to existing coverage result to merge.", Arity = ArgumentArity.ZeroOrOne }; |
52 |
| - CliOption<bool> useSourceLink = new ("--use-source-link") { Description = "Specifies whether to use SourceLink URIs in place of file system paths.", Arity = ArgumentArity.Zero }; |
53 |
| - CliOption<string[]> doesNotReturnAttributes = new ("--does-not-return-attribute") { Description = "Attributes that mark methods that do not return", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
54 |
| - CliOption<string> excludeAssembliesWithoutSources = new ("--exclude-assemblies-without-sources") { Description = "Specifies behaviour of heuristic to ignore assemblies with missing source documents.", Arity = ArgumentArity.ZeroOrOne }; |
55 |
| - CliOption<string> sourceMappingFile = new ("--source-mapping-file") { Description = "Specifies the path to a SourceRootsMappings file.", Arity = ArgumentArity.ZeroOrOne }; |
56 |
| - |
57 |
| - CliRootCommand rootCommand = new("Cross platform .NET Core code coverage tool") |
| 42 | + Option<ThresholdStatistic> thresholdStat = new("--threshold-stat") { DefaultValueFactory = (_) => ThresholdStatistic.Minimum, Description = "Coverage statistic used to enforce the threshold value.", Arity = ArgumentArity.ZeroOrOne }; |
| 43 | + Option<string[]> excludeFilters = new("--exclude") { Description = "Filter expressions to exclude specific modules and types.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
| 44 | + Option<string[]> includeFilters = new("--include") { Description = "Filter expressions to include only specific modules and types.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
| 45 | + Option<string[]> excludedSourceFiles = new("--exclude-by-file") { Description = "Glob patterns specifying source files to exclude.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
| 46 | + Option<string[]> includeDirectories = new("--include-directory") { Description = "Include directories containing additional assemblies to be instrumented.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
| 47 | + Option<string[]> excludeAttributes = new("--exclude-by-attribute") { Description = "Attributes to exclude from code coverage.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
| 48 | + Option<bool> includeTestAssembly = new("--include-test-assembly") { Description = "Specifies whether to report code coverage of the test assembly.", Arity = ArgumentArity.Zero }; |
| 49 | + Option<bool> singleHit = new("--single-hit") { Description = "Specifies whether to limit code coverage hit reporting to a single hit for each location", Arity = ArgumentArity.Zero }; |
| 50 | + Option<bool> skipAutoProp = new("--skipautoprops") { Description = "Neither track nor record auto-implemented properties.", Arity = ArgumentArity.Zero }; |
| 51 | + Option<string> mergeWith = new("--merge-with") { Description = "Path to existing coverage result to merge.", Arity = ArgumentArity.ZeroOrOne }; |
| 52 | + Option<bool> useSourceLink = new("--use-source-link") { Description = "Specifies whether to use SourceLink URIs in place of file system paths.", Arity = ArgumentArity.Zero }; |
| 53 | + Option<string[]> doesNotReturnAttributes = new("--does-not-return-attribute") { Description = "Attributes that mark methods that do not return", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; |
| 54 | + Option<string> excludeAssembliesWithoutSources = new("--exclude-assemblies-without-sources") { Description = "Specifies behaviour of heuristic to ignore assemblies with missing source documents.", Arity = ArgumentArity.ZeroOrOne }; |
| 55 | + Option<string> sourceMappingFile = new("--source-mapping-file") { Description = "Specifies the path to a SourceRootsMappings file.", Arity = ArgumentArity.ZeroOrOne }; |
| 56 | + |
| 57 | + RootCommand rootCommand = new("Cross platform .NET Core code coverage tool") |
58 | 58 | {
|
59 | 59 | moduleOrAppDirectory,
|
60 | 60 | target,
|
@@ -82,7 +82,7 @@ static async Task Main(string[] args)
|
82 | 82 | rootCommand.Add(new HelpOption());
|
83 | 83 | rootCommand.Add(new VersionOption());
|
84 | 84 |
|
85 |
| - ParseResult parseResult = CliParser.Parse(rootCommand, args); |
| 85 | + ParseResult parseResult = CommandLineParser.Parse(rootCommand, args); |
86 | 86 |
|
87 | 87 | rootCommand.SetAction(async (context) =>
|
88 | 88 | {
|
@@ -138,7 +138,7 @@ static async Task Main(string[] args)
|
138 | 138 |
|
139 | 139 | });
|
140 | 140 |
|
141 |
| - CliConfiguration config = new(rootCommand); |
| 141 | + CommandLineConfiguration config = new(rootCommand); |
142 | 142 |
|
143 | 143 | await config.InvokeAsync(args).ConfigureAwait(false);
|
144 | 144 | Environment.Exit(s_exitCode);
|
@@ -392,7 +392,7 @@ string sourceMappingFile
|
392 | 392 | }
|
393 | 393 | logger.LogError(errorMessageBuilder.ToString());
|
394 | 394 | }
|
395 |
| - |
| 395 | + |
396 | 396 | return Task.FromResult(s_exitCode);
|
397 | 397 |
|
398 | 398 | }
|
|
0 commit comments