Ookii.CommandLine
4.2.0
dotnet add package Ookii.CommandLine --version 4.2.0
NuGet\Install-Package Ookii.CommandLine -Version 4.2.0
<PackageReference Include="Ookii.CommandLine" Version="4.2.0" />
paket add Ookii.CommandLine --version 4.2.0
#r "nuget: Ookii.CommandLine, 4.2.0"
// Install Ookii.CommandLine as a Cake Addin #addin nuget:?package=Ookii.CommandLine&version=4.2.0 // Install Ookii.CommandLine as a Cake Tool #tool nuget:?package=Ookii.CommandLine&version=4.2.0
Ookii.CommandLine
Ookii.CommandLine is a powerful, flexible and highly customizable command line argument parsing library for .Net applications.
- Easily define arguments by creating a class with properties.
- Create applications with multiple subcommands.
- Generate fully customizable usage help.
- Supports PowerShell-like and POSIX-like parsing rules.
- Compatible with trimming and native AOT.
Two styles of command line parsing rules are supported: the default mode uses rules similar to those used by PowerShell, and the alternative long/short mode uses a style influenced by POSIX conventions, where arguments have separate long and short names with different prefixes. Many aspects of the parsing rules are configurable.
To determine which arguments are accepted, you create a class, with properties and methods that define the arguments. Attributes are used to specify names, create required or positional arguments, and to specify descriptions for use in the generated usage help.
For example, the following class defines four arguments: a required positional argument, an optional positional argument, a named-only argument, and a switch argument (sometimes also called a flag):
[GeneratedParser]
partial class MyArguments
{
[CommandLineArgument(IsPositional = true)]
[Description("A required positional argument.")]
public required string Required { get; set; }
[CommandLineArgument(IsPositional = true)]
[Description("An optional positional argument.")]
public int Optional { get; set; } = 42;
[CommandLineArgument]
[Description("An argument that can only be supplied by name.")]
public DateTime Named { get; set; }
[CommandLineArgument]
[Description("A switch argument, which doesn't require a value.")]
public bool Switch { get; set; }
}
Each argument has a different type that determines the kinds of values it can accept.
If you are using an older version of .Net where the
required
keyword is not available, you can use[CommandLineArgument(IsRequired = true)]
to create a required argument instead.
To parse these arguments, all you have to do is add the following line to your Main
method:
var arguments = MyArguments.Parse();
In addition, Ookii.CommandLine can be used to create applications that have multiple subcommands, each with their own arguments.
For more information, including a tutorial and samples, see the full documentation on GitHub.
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 is compatible. 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. |
.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 is compatible. |
.NET Framework | 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. |
-
.NETStandard 2.0
- System.Collections.Immutable (>= 8.0.0)
- System.Memory (>= 4.5.5)
-
.NETStandard 2.1
- System.Collections.Immutable (>= 8.0.0)
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.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.2.0 | 1,280 | 9/12/2024 |
4.2.0-preview2 | 102 | 8/29/2024 |
4.2.0-preview | 99 | 8/28/2024 |
4.1.0 | 7,579 | 1/26/2024 |
4.0.1 | 1,629 | 9/19/2023 |
4.0.0 | 713 | 7/20/2023 |
3.1.1 | 5,284 | 3/29/2023 |
3.1.0 | 372 | 3/21/2023 |
3.0.0 | 6,843 | 12/1/2022 |
2.4.0 | 3,283 | 9/1/2022 |
2.3.0 | 32,950 | 9/5/2019 |
2.2.0 | 104,988 | 2/6/2013 |
2.1.0 | 2,699 | 2/20/2012 |
This version contains breaking changes compared to version 2.x and 3.x. For details, please view: https://www.ookii.org/Link/CommandLineVersionHistory