Skip to content

Commit d86dd03

Browse files
authored
Merge pull request #1 from askids/ILogger-Support
ILogger support
2 parents 89c0575 + b7778ff commit d86dd03

32 files changed

Lines changed: 226 additions & 146 deletions

Generate-ReleaseNotes.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
rem See https://github.com/StefH/GitHubReleaseNotes for more information.
22

3-
SET version=3.0.23
3+
SET version=3.1.0
44

55
GitHubReleaseNotes --output ReleaseNotes.md --skip-empty-releases --exclude-labels question invalid doc --version %version%

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ CommandLine Parser Library lets you easily define strongly typed command line ar
99
See [Quick Start](https://github.com/j-maly/CommandLineParser/wiki) on how to use the library.
1010

1111
Supports the following Frameworks:
12-
* NET 2.0
13-
* NET 3.5
14-
* NET 4.0
15-
* NET 4.5
16-
* NET 4.5.2 and higher
17-
* NETStandard 1.3 and higher
1812
* NETStandard 2.0
1913
* NETStandard 2.1
2014

@@ -32,7 +26,9 @@ For application with one or two arguments, you could probably manage with some s
3226

3327
This is the way you define arguments for your application:
3428
```csharp
35-
CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser();
29+
var factory = LoggerFactory.Create(b => b.AddConsole());
30+
ILogger<CommandLineParser.CommandLineParser> logger = factory.CreateLogger<CommandLineParser.CommandLineParser>();
31+
CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser(logger);
3632
//switch argument is meant for true/false logic
3733
SwitchArgument showArgument = new SwitchArgument('s', "show", "Set whether show or not", true);
3834
ValueArgument<decimal> version = new ValueArgument<decimal>('v', "version", "Set desired version");
@@ -60,7 +56,7 @@ try
6056
}
6157
catch (CommandLineException e)
6258
{
63-
Console.WriteLine(e.Message);
59+
logger.LogWarning(e.Message);
6460
}
6561
```
6662
You can find more examples of use in the [wiki](https://github.com/j-maly/CommandLineParser/wiki).

ReleaseNotes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 3.1.0 (13 August 2022)
2+
- [#82](https://github.com/j-maly/CommandLineParser/pull/82) - Replace Console.Write with ILogger using Microsoft Logging extenions. Also standardized support for only .Net Standard 2.0 and 2.1 [enhancement] contributed by [askids](https://github.com/askids)
3+
14
# 3.0.23 (04 August 2022)
25
- [#74](https://github.com/j-maly/CommandLineParser/pull/74) - Bump System.Text.RegularExpressions from 4.3.0 to 4.3.1 in /src/CommandLineArgumentsParser [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
36
- [#80](https://github.com/j-maly/CommandLineParser/pull/80) - Fixed RegexValueArgumentAttribute [bug] contributed by [StefH](https://github.com/StefH)

appveyor.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
os: Visual Studio 2022
22

3-
version: 3.0.23.{build}
3+
version: 3.1.0.{build}
44

55
configuration:
66
- Debug
@@ -15,13 +15,13 @@ build_script:
1515
- cmd: dotnet --info
1616

1717
- cmd: dotnet restore src\CommandLineArgumentsParser\CommandLineArgumentsParser.csproj
18-
- cmd: dotnet build src\CommandLineArgumentsParser\CommandLineArgumentsParser.csproj --configuration %CONFIGURATION% --framework net452
19-
- cmd: dotnet build src\CommandLineArgumentsParser\CommandLineArgumentsParser.csproj --configuration %CONFIGURATION% --framework netstandard1.3
18+
- cmd: dotnet build src\CommandLineArgumentsParser\CommandLineArgumentsParser.csproj --configuration %CONFIGURATION% --framework netstandard2.0
19+
- cmd: dotnet build src\CommandLineArgumentsParser\CommandLineArgumentsParser.csproj --configuration %CONFIGURATION% --framework netstandard2.1
2020

2121
- cmd: dotnet restore src\ParserTest\ParserTest.csproj
22-
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework net452
23-
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework netcoreapp1.1
24-
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework netcoreapp2.1
22+
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework net472
23+
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework net48
24+
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework netcoreapp3.1
2525
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework net6.0
2626

2727
- cmd: dotnet restore src\Tests\Tests.csproj

src/CommandLineArgumentsParser/Arguments/Argument.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Reflection;
55
using CommandLineParser.Compatibility;
66
using CommandLineParser.Exceptions;
7+
using Microsoft.Extensions.Logging;
78

89
namespace CommandLineParser.Arguments;
910

@@ -251,9 +252,9 @@ public virtual void Parse(IList<string> args, ref int i)
251252
}
252253

253254
/// <summary>
254-
/// Prints information about the argument value to the console.
255+
/// Prints information about the argument value to the log.
255256
/// </summary>
256-
public abstract void PrintValueInfo();
257+
public abstract void PrintValueInfo(ILogger logger);
257258

258259
/// <summary>
259260
/// Initializes the argument. Sets <see cref="Parsed"/> to false. Override in inherited classes

src/CommandLineArgumentsParser/Arguments/BoundedValueArgument.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using CommandLineParser.Compatibility;
33
using CommandLineParser.Exceptions;
4+
using Microsoft.Extensions.Logging;
45

56
namespace CommandLineParser.Arguments
67
{

src/CommandLineArgumentsParser/Arguments/CertifiedValueArgument.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using Microsoft.Extensions.Logging;
2+
using System.Collections.Generic;
23

34
namespace CommandLineParser.Arguments
45
{

src/CommandLineArgumentsParser/Arguments/DirectoryArgument.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.Extensions.Logging;
12
using System.IO;
23

34
namespace CommandLineParser.Arguments

src/CommandLineArgumentsParser/Arguments/EnumeratedValueArgument.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using CommandLineParser.Compatibility;
55
using CommandLineParser.Exceptions;
6+
using Microsoft.Extensions.Logging;
67

78
namespace CommandLineParser.Arguments
89
{

src/CommandLineArgumentsParser/Arguments/FileArgument.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.Extensions.Logging;
12
using System;
23
using System.IO;
34

0 commit comments

Comments
 (0)