SimpleCommandlineParser 1.4.2
dotnet add package SimpleCommandlineParser --version 1.4.2
NuGet\Install-Package SimpleCommandlineParser -Version 1.4.2
<PackageReference Include="SimpleCommandlineParser" Version="1.4.2" />
<PackageVersion Include="SimpleCommandlineParser" Version="1.4.2" />
<PackageReference Include="SimpleCommandlineParser" />
paket add SimpleCommandlineParser --version 1.4.2
#r "nuget: SimpleCommandlineParser, 1.4.2"
#:package SimpleCommandlineParser@1.4.2
#addin nuget:?package=SimpleCommandlineParser&version=1.4.2
#tool nuget:?package=SimpleCommandlineParser&version=1.4.2
SimpleCommandLineParser
Simple and straight forward command line parser for dotnet console apps.
Version 1.4.1 includes a refreshed list of target frameworks, and removes dependencies on a number of other libraries.
Breaking changes:
As of version 1.4.0...
- the constructor wants an application name and description as parameters
- the lambdas passed to the parameter methods are now Action<T> instead of Action<string>, T being the type of the parameter. This allows for better type checking and less casting.
Bug fixes:
Handle optional parameters.
Usage:
namespace UsageExample
{
using System;
using SimpleCommandlineParser;
static class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var parser = new Parser("SimpleCommandlineParser", "SimpleCommandlineParser usage example")
.WithHelpWriter(Console.WriteLine)
.WithErrorWriter(Console.Error.WriteLine)
.AddHelpSwitch()
.AddSwitch("mySwitch", () => Console.WriteLine($"Got a switch called mySwitch"), "command line switch")
.AddStringParameter("Command", a => Console.WriteLine($"Command parameter: {a}"), "The command to be executed")
.AddOptionalStringParameter("OptionalString", a => Console.WriteLine($"OptionalStringArgument: {a}"), "An optional String argument")
.AddIntegerParameter("Number", a => Console.WriteLine($"Got a Number argument:{a}"), "An integer argument")
.AddOptionalIntegerParameter("OptionalNumber", a => Console.WriteLine($"Got an optional Number argument:{a}"), "An optional integer argument")
.AddDecimalParameter("Decimal", a => Console.WriteLine($"Got a Number argument:{a}"), "An Decimal argument")
.AddOptionalDecimalParameter("OptionalDecimal", a => Console.WriteLine($"Got an optional Number argument:{a}"), "An optional Decimal argument")
.AddDateParameter("Date", a => Console.WriteLine($"Got a Date argument:{a:D}"), "A date argument")
.AddOptionalDateParameter("OptionalDate", a => Console.WriteLine($"Got an optional Date argument:{a}"), "An optional date argument")
.AddDateTimeParameter("DateTime", a => Console.WriteLine($"Got a DateTime argument:{a:O}"), "A DateTime argument")
.AddOptionalDateTimeParameter("OptionalDateTime", a => Console.WriteLine($"Got an optional DateTime argument:{a}"), "An optional DateTime argument")
.Run(args);
parser.EchoParameters();
Console.WriteLine(parser.GetHelp());
}
}
}
When called as
UsageExample --MySwitch --number=1 --command=HelloWorld --decimal=3.14 --date=1961-12-28 --datetime=1961-12-28T18:00
the output of this simple console app would be:
Hello World!
Got a switch called mySwitch
Command parameter: HelloWorld
Got a Number argument:1
Got a Number argument:3.14
Got a Date argument:1961-12-28
Got a DateTime argument:1961-12-28T18:00:00.0000000
SimpleCommandlineParser running with parameters: --myswitch --number=1 --command=HelloWorld --decimal=3.14 --date=1961-12-28 --datetime=1961-12-28T18:00
SimpleCommandlineParser usage example
SimpleCommandlineParser usage is:
[--help] : Get help on parameters
[--myswitch] : command line switch
--command : The command to be executed
[--optionalstring] : An optional String argument
--number : An integer argument
[--optionalnumber] : An optional integer argument
--decimal : An Decimal argument
[--optionaldecimal] : An optional Decimal argument
--date : A date argument
[--optionaldate] : An optional date argument
--datetime : A DateTime argument
[--optionaldatetime] : An optional DateTime argument
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Release 1.2 introduced chainable methods to add parameters ane invoke parsing, lambdas and switch actions.
Release 1.4 refreshes the target frameworks and removes dependencies on 3rd party packages. Adding strong type checking on typed parameters (numbers and datetimes)