deniszykov.CommandLine 2.0.6

.NET 5.0 .NET Core 3.1 .NET Standard 1.6 .NET Framework 4.5
dotnet add package deniszykov.CommandLine --version 2.0.6
NuGet\Install-Package deniszykov.CommandLine -Version 2.0.6
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="deniszykov.CommandLine" Version="2.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add deniszykov.CommandLine --version 2.0.6
#r "nuget: deniszykov.CommandLine, 2.0.6"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install deniszykov.CommandLine as a Cake Addin
#addin nuget:?package=deniszykov.CommandLine&version=2.0.6

// Install deniszykov.CommandLine as a Cake Tool
#tool nuget:?package=deniszykov.CommandLine&version=2.0.6



A simple getopt styled command line library.


Install-Package deniszykov.CommandLine

For .NET Core Hosted environment:

Install-Package deniszykov.CommandLine.Hosted

.NET Core Hosted Example

Quick Start

To start, you need to configure the entry point to the application:

public class Program
  private static int Main(string[] arguments) =>
      .Use<Program>() // set class with verbs/commands

  public static int Hello(string name)
    Console.WriteLine("Hello " + name + "!");
    return 0; // exit code

Full Example Code

CommandLine relies on reflection to find method to invoke.
This method should return int value which is interpreted as Exit Code of application.
Asynchronous entry points and methods are also supported. To do this, use method RunAsync() and Task<int> as return type.

When you could request help for your application:

> myapp /?

This test application. Type /? for help.

    HELLO    Says hello to specified 'name'.

Or invoke Hello(string name) with following command:

> myapp hello --name Jake

Hello Jake!


Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard1.6 netstandard2.0 netstandard2.1
.NET Framework net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen30 tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on deniszykov.CommandLine:

Package Downloads

.NET Core hosted command line parser and binder. Provides API for parsing and binding command line arguments to .NET methods.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.6 530 10/7/2022
2.0.0 787 3/5/2021

# 2.0.2 - 2.0.6
- added posibility to use multiple c# classes as combined source of verbs
- updated dependencies
# 2.0.1
- updated target frameworks for 'Hosted' version of package to include .NET Framework 4.6.1
# 2.0.0
- rewritten as a service
- commands, Parameters are now Verbs, Options, Values
- now follows getOpt syntax
- services could be injected in parameters
- verbs are now could be async and cancelled
- configuration is now in separate class
- help request is build-in and doesn't require custom 'Help' command
- console has been abstracted and could be replaced
- help text is now localizable
- fixed bugs with help text and sub-verbs
# 1.3.1 - 1.3.2
- TypeConvert dependecy update (bug fixes)
# 1.3.0
- added TypeConverterAttribute support on command parameters. It's takes precendence before any other types of type conversions.
# 1.2.9
- added netcoreapp2.1 target platform
- dependencies update (internal)
# 1.2.7
- fixed exception when calling Describe while console output is redirected
- TypeConvert package update
# 1.2.6
- TypeConvert package update
- documentation update
# 1.2.5
- added WriteWholeErrorMessageOnBindFailure option for debugging purpose (it writes descriptive error message to stderr stream)
- added DescribeExitCode option for controlling exit code of Describe method
- tuned error messages when no command is specified or wrong parameters are passed
- tuned Describe method for better description text (friendly type names, nullable types support etc...)
# 1.2.4
- fixed binding error when no default action is specified
- added XML documentation file to package
# 1.2.3
- updated references for .NET Core Targets and .NET Standard
# 1.2.2
- returned original library name ConsoleApp.CommandLine.dll
# 1.2.1
- embedded TypeConvert dependency
# 1.2.0
- CommandLine.UnhandledException type changed to ExceptionEventHandler
- added custom description attributes as replacement to System.ComponentModel attributes: HelpTextAttribute and HiddenAttribute
- added support of .NET Standard platform
# 1.1.3
- refactored error messages fo parameters binding failure cases.
- added CommandLineException to signal binding failures.
- fixed few array parameter binding bugs
# 1.1.2
- added bare double hyphen to enforce positional parameters
- added bare single hyphen to disable hyphen interpretation in values
- added special treatment for negative numbers
- added CommandLine.DescribeOnBindFailure which controls reaction on method binding failure (true to run CommandLine.Describe(), false to throw exception).
- added enum flags binding subroutine, now "--flag Flag1 Flag2 Flag3" arguments are supported.
- changed method binding order to from most parameters to less (original was chaotic), binding strategy is still - "first match".
- added non-generic Run and Describe methods
- fixed bug with positional parameters binding
# 1.0.0
- initial release