Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Generate-ReleaseNotes.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rem See https://github.com/StefH/GitHubReleaseNotes for more information.

SET version=3.0.23
SET version=3.1.0

GitHubReleaseNotes --output ReleaseNotes.md --skip-empty-releases --exclude-labels question invalid doc --version %version%
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ CommandLine Parser Library lets you easily define strongly typed command line ar
See [Quick Start](https://github.com/j-maly/CommandLineParser/wiki) on how to use the library.

Supports the following Frameworks:
* NET 2.0
* NET 3.5
* NET 4.0
* NET 4.5
* NET 4.5.2 and higher
* NETStandard 1.3 and higher
* NETStandard 2.0
* NETStandard 2.1

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

This is the way you define arguments for your application:
```csharp
CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser();
var factory = LoggerFactory.Create(b => b.AddConsole());
ILogger<CommandLineParser.CommandLineParser> logger = factory.CreateLogger<CommandLineParser.CommandLineParser>();
CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser(logger);
//switch argument is meant for true/false logic
SwitchArgument showArgument = new SwitchArgument('s', "show", "Set whether show or not", true);
ValueArgument<decimal> version = new ValueArgument<decimal>('v', "version", "Set desired version");
Expand Down Expand Up @@ -60,7 +56,7 @@ try
}
catch (CommandLineException e)
{
Console.WriteLine(e.Message);
logger.LogWarning(e.Message);
}
```
You can find more examples of use in the [wiki](https://github.com/j-maly/CommandLineParser/wiki).
Expand Down
3 changes: 3 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 3.1.0 (13 August 2022)
- [#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.0.23 (04 August 2022)
- [#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)
- [#80](https://github.com/j-maly/CommandLineParser/pull/80) - Fixed RegexValueArgumentAttribute [bug] contributed by [StefH](https://github.com/StefH)
Expand Down
12 changes: 6 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
os: Visual Studio 2022

version: 3.0.23.{build}
version: 3.1.0.{build}

configuration:
- Debug
Expand All @@ -15,13 +15,13 @@ build_script:
- cmd: dotnet --info

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

- cmd: dotnet restore src\ParserTest\ParserTest.csproj
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework net452
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework netcoreapp1.1
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework netcoreapp2.1
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework net472
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework net48
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework netcoreapp3.1
- cmd: dotnet build src\ParserTest\ParserTest.csproj --configuration %CONFIGURATION% --framework net6.0

- cmd: dotnet restore src\Tests\Tests.csproj
Expand Down
5 changes: 3 additions & 2 deletions src/CommandLineArgumentsParser/Arguments/Argument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Reflection;
using CommandLineParser.Compatibility;
using CommandLineParser.Exceptions;
using Microsoft.Extensions.Logging;

namespace CommandLineParser.Arguments;

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

/// <summary>
/// Prints information about the argument value to the console.
/// Prints information about the argument value to the log.
/// </summary>
public abstract void PrintValueInfo();
public abstract void PrintValueInfo(ILogger logger);

/// <summary>
/// Initializes the argument. Sets <see cref="Parsed"/> to false. Override in inherited classes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using CommandLineParser.Compatibility;
using CommandLineParser.Exceptions;
using Microsoft.Extensions.Logging;

namespace CommandLineParser.Arguments
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;

namespace CommandLineParser.Arguments
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.Extensions.Logging;
using System.IO;

namespace CommandLineParser.Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using CommandLineParser.Compatibility;
using CommandLineParser.Exceptions;
using Microsoft.Extensions.Logging;

namespace CommandLineParser.Arguments
{
Expand Down
1 change: 1 addition & 0 deletions src/CommandLineArgumentsParser/Arguments/FileArgument.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.Extensions.Logging;
using System;
using System.IO;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Text.RegularExpressions;
using CommandLineParser.Compatibility;
using CommandLineParser.Exceptions;
using Microsoft.Extensions.Logging;

namespace CommandLineParser.Arguments;

Expand Down
7 changes: 4 additions & 3 deletions src/CommandLineArgumentsParser/Arguments/SwitchArgument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using CommandLineParser.Compatibility;
using CommandLineParser.Exceptions;
using Microsoft.Extensions.Logging;

namespace CommandLineParser.Arguments
{
Expand Down Expand Up @@ -113,11 +114,11 @@ public override void UpdateBoundObject()
}

/// <summary>
/// Prints information about the argument value to the console.
/// Prints information about the argument value to the ILogger.
/// </summary>
public override void PrintValueInfo()
public override void PrintValueInfo(ILogger logger)
{
Console.WriteLine(Messages.EXC_ARG_SWITCH_PRINT, Name, Value ? "1" : "0");
logger.LogInformation(Messages.IL_EXC_ARG_SWITCH_PRINT, Name, Value ? "1" : "0");
}

/// <summary>
Expand Down
9 changes: 5 additions & 4 deletions src/CommandLineArgumentsParser/Arguments/ValueArgument.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CommandLineParser.Compatibility;
using CommandLineParser.Exceptions;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down Expand Up @@ -442,18 +443,18 @@ public override void Init()
}

/// <summary>
/// Prints information about the argument value to the console.
/// Prints information about the argument value to the log.
/// </summary>
public override void PrintValueInfo()
public override void PrintValueInfo(ILogger logger)
{
if (!AllowMultiple)
{
Console.WriteLine(Messages.EXC_ARG_VALUE_PRINT, Name, _stringValue, _value, typeof(TValue).Name);
logger.LogInformation(Messages.IL_EXC_ARG_VALUE_PRINT, Name, _stringValue, _value, typeof(TValue).Name);
}
else
{
string valuesString = string.Join(", ", _values.Select(v => v.ToString()).ToArray());
Console.WriteLine(Messages.EXC_ARG_VALUE_PRINT_MULTIPLE, Name, Values.Count, valuesString, typeof(TValue).Name);
logger.LogInformation(Messages.IL_EXC_ARG_VALUE_PRINT_MULTIPLE, Name, Values.Count, valuesString, typeof(TValue).Name);
}
}
}
Expand Down
31 changes: 5 additions & 26 deletions src/CommandLineArgumentsParser/CommandLineArgumentsParser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Authors>Jakub Maly;Stef Heyenrath;NTTAKR</Authors>
<Copyright>Copyright Jakub Maly &amp; Stef Heyenrath © 2018-2022</Copyright>
<Company>Jakub Maly</Company>
<TargetFrameworks>net20;net35;net40;net45;net452;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<AssemblyName>CommandLineArgumentsParser</AssemblyName>
<RootNamespace>CommandLineParser</RootNamespace>
<PackageId>CommandLineArgumentsParser</PackageId>
Expand All @@ -16,7 +16,7 @@
<PackageReleaseNotes>See ReleaseNotes.md</PackageReleaseNotes>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/j-maly/CommandLineParser</RepositoryUrl>
<Version>3.0.23</Version>
<Version>3.1.0</Version>
<DebugType>full</DebugType>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>CommandLineArgumentsParser.snk</AssemblyOriginatorKeyFile>
Expand All @@ -30,30 +30,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net20' ">
<PackageReference Include="LinqBridge" Version="1.3.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Console" Version="4.3.0" />
<PackageReference Include="System.Globalization" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.Linq" Version="4.3.0" />
<PackageReference Include="System.Reflection.Extensions" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
<PackageReference Include="System.Resources.ResourceManager" Version="4.3.0" />
<PackageReference Include="System.Runtime.Extensions" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

</Project>
Loading