MyOddWeb.CommandlineParser 0.1.3

A fast and reliable .NET command line parser
   
Supported platforms:
- .NET Framework 4.5.2+
- .NET Standard 1.3
- .NET Standard 2.0
- .NET Core

Requires NuGet 2.12 or higher.

Install-Package MyOddWeb.CommandlineParser -Version 0.1.3
dotnet add package MyOddWeb.CommandlineParser --version 0.1.3
<PackageReference Include="MyOddWeb.CommandlineParser" Version="0.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MyOddWeb.CommandlineParser --version 0.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Myoddweb.CommandlineParser Release

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

NuGet Status
NuGet Count

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, "-" );
    ...

Myoddweb.CommandlineParser Release

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

NuGet Status
NuGet Count

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, "-" );
    ...

  • .NETFramework 4.5.2

    • No dependencies.
  • .NETStandard 1.3

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.1.3 152 4/14/2019
0.1.2 90 4/2/2019
0.1.1 90 4/1/2019
0.1.0 117 2/14/2019