Ookii.CommandLine 2.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ookii.CommandLine --version 2.4.0
NuGet\Install-Package Ookii.CommandLine -Version 2.4.0
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="Ookii.CommandLine" Version="2.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ookii.CommandLine --version 2.4.0
#r "nuget: Ookii.CommandLine, 2.4.0"
#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 Ookii.CommandLine as a Cake Addin
#addin nuget:?package=Ookii.CommandLine&version=2.4.0

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

Ookii.CommandLine

Ookii.CommandLine enables comprehensive command line argument parsing for .Net applications. It allows you to easily define required, optional, positional and named arguments, parse the command line, and generate usage information. It is provided in versions for .Net Framework 2.0 and later, .Net Standard 2.0, and .Net 6.0 and later.

Accompanying code snippets are available on the Visual Studio marketplace.

Overview

Ookii.CommandLine is a library that helps you to parse command line arguments for your applications. It allows you to easily define a set of accepted arguments, and then parse the command line supplied to your application for those arguments. In addition, it allows you to generate usage help from the arguments that you defined which you can display to the user.

Ookii.CommandLine can be used with any kind of .Net application, whether Console, Windows Forms, or WPF. Although a limited subset of functionality – particularly related around generating usage help text – is geared primarily towards console applications that are invoked from the command prompt, the main command line parsing functionality is usable in any application that needs to process command line arguments.

To define a set of command line arguments, you create a class that will hold their values. The constructor parameters and properties of that class determine the set of arguments that are accepted. Attributes can be used to specify things such as the argument name and whether or not an argument is required, and to specify descriptions used to customize the usage help.

Command line parsing is done in a way that is similar to that used by Windows PowerShell. Each argument has a name, and can be supplied by name on the command line. An argument can also be positional, in which case it can be supplied without the name. Arguments can be required or optional, and there is support for switch arguments (which don't need a value but are either present or not) and arguments with multiple values. Various aspects of the parsing, such as the argument name prefix (typically a / or a -), can be customized.

For example, the following class defines four arguments: a required positional argument, an optional positional argument, a named argument, and a switch argument:

class MyArguments
{
    [CommandLineArgument(Position = 0, IsRequired = true)]
    public string RequiredArgument { get; set; }
    [CommandLineArgument(Position = 1)]
    public int OptionalArgument { get; set; }
    [CommandLineArgument]
    public DateTime NamedArgument { get; set; }
    [CommandLineArgument]
    public bool SwitchArgument { get; set; }
}

The application using these arguments would have the following usage syntax (this kind of usage help can be generated by Ookii.CommandLine, and can be customized to include argument descriptions):

Usage: MyApplication.exe [-RequiredArgument] <String> [[-OptionalArgument] <Number>] [-NamedArgument <DateTime>] [-SwitchArgument]

An example invocation of this application, specifying all the arguments, would look like this:

MyApplication.exe foo 42 -SwitchArgument -NamedArgument 2019-08-14

There is also functionality for creating command line utilities that perform multiple operations, each with their own arguments (these are called ShellCommands in Ookii.CommandLine).

Please see the Documentation for more information, and also check out the Class Library documentation.

Product 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 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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net20 is compatible.  net35 was computed.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 2.0

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Ookii.CommandLine:

Repository Stars
Ourpalm/ILRuntime
Pure C# IL Intepreter Runtime, which is fast and reliable for scripting requirement on enviorments, where jitting isn't possible.
servicetitan/Stl.Fusion.Samples
A collection of samples for Fusion library: https://github.com/servicetitan/Stl.Fusion
Version Downloads Last updated
4.1.0 2,148 1/26/2024
4.0.1 1,121 9/19/2023
4.0.0 634 7/20/2023
3.1.1 3,070 3/29/2023
3.1.0 324 3/21/2023
3.0.0 6,018 12/1/2022
2.4.0 946 9/1/2022
2.3.0 27,491 9/5/2019
2.2.0 97,309 2/6/2013
2.1.0 2,641 2/20/2012

For details, please view: https://github.com/SvenGroot/ookii.commandline/blob/master/docs/What's New in Ookii.CommandLine.md