MyOddWeb.CommandlineParser
0.1.2
See the version list below for details.
Requires NuGet 2.12 or higher.
dotnet add package MyOddWeb.CommandlineParser --version 0.1.2
NuGet\Install-Package MyOddWeb.CommandlineParser -Version 0.1.2
<PackageReference Include="MyOddWeb.CommandlineParser" Version="0.1.2" />
paket add MyOddWeb.CommandlineParser --version 0.1.2
#r "nuget: MyOddWeb.CommandlineParser, 0.1.2"
// Install MyOddWeb.CommandlineParser as a Cake Addin #addin nuget:?package=MyOddWeb.CommandlineParser&version=0.1.2 // Install MyOddWeb.CommandlineParser as a Cake Tool #tool nuget:?package=MyOddWeb.CommandlineParser&version=0.1.2
Myoddweb.CommandlineParser
A very simple c# command line arguments Parser
What it does
- Very simple command line parser for c#
- Simple to import/install
- Simple to use
- You can create optional parametters
- You can create help output.
Installing
Nuget
Package manager
Install-Package MyOddWeb.CommandlineParser
CLI
.NET
dotnet add package MyOddWeb.CommandlineParser
Packet
paket add MyOddWeb.CommandlineParser
Example
Lets say that we have a application that has command line options to install
and run as a console
using myoddweb.commandlineparser;
private void Bar()
{
...
var arguments = new CommandlineParser(args, new Dictionary<string, CommandlineData>
{
{ "config", new CommandlineData{ IsRequired = false, DefaultValue = "config.json"}},
{ "install", new CommandlineData{ IsRequired = false} },
{ "console", new CommandlineData{ IsRequired = false} }
});
...
}
We can then check if we are running as a console
if (arguments.IsSet("console"))
{
InvokeActionInstall();
return;
}
We can also call the config value as we know it exists... (we have a default value)
...
var config = _arguments["config"];
...
We can also get a default value directly
For example, in the example below, we will either get the number that was passed, (example.exe --a 32
), or the default value.
The value itself will be an integer, as this is what we expect...
...
var theGalaxy = parser.Get<int>("a", 42)
...
The argument does not have to have a value, for example you could have example.exe --a --b
In that case you would simply defaule
...
var arguments = new CommandlineParser(args, null );
...
What if you want a different leading pattern ...? Something like example.exe -a -b
Simply pass it as a third argument ...
...
var arguments = new CommandlineParser(args, null, "-" );
...
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. netstandard2.2 is compatible. |
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5.2
- No dependencies.
-
.NETStandard 2.1
- NETStandard.Library (>= 2.1.0)
-
.NETStandard 2.2
- NETStandard.Library (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.