NetLah.Extensions.CommandLineUtils 0.1.0-a1.2

The ID prefix of this package has been reserved for one of the owners of this package by Prefix Reserved
.NET Standard 2.1
This is a prerelease version of NetLah.Extensions.CommandLineUtils.
dotnet add package NetLah.Extensions.CommandLineUtils --version 0.1.0-a1.2
NuGet\Install-Package NetLah.Extensions.CommandLineUtils -Version 0.1.0-a1.2
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="NetLah.Extensions.CommandLineUtils" Version="0.1.0-a1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetLah.Extensions.CommandLineUtils --version 0.1.0-a1.2
#r "nuget: NetLah.Extensions.CommandLineUtils, 0.1.0-a1.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install NetLah.Extensions.CommandLineUtils as a Cake Addin
#addin nuget:?package=NetLah.Extensions.CommandLineUtils&version=0.1.0-a1.2&prerelease

// Install NetLah.Extensions.CommandLineUtils as a Cake Tool
#tool nuget:?package=NetLah.Extensions.CommandLineUtils&version=0.1.0-a1.2&prerelease

NetLah.Extensions.CommandLineUtils - .NET Library

NetLah.Extensions.CommandLineUtils Command line parsing for .NET.

Nuget package


Build Status


Getting started

1. Add/Update PackageReference to web .csproj

  <PackageReference Include="NetLah.Extensions.CommandLineUtils" />

2. Sample Command Line Application

CommandLineApplication commandLineApplication =
    new(throwOnUnexpectedArg: false)
        Name = "SampleCommandLine.exe",
        FullName = "SampleCommandLine: greeting a fullname"

CommandArgument? names = null;

    (target) =>
        target.FullName = "Greeting a fullname";
        target.Description = "The hello command";
        target.ShortVersionGetter = GetShortVersion;
        target.LongVersionGetter = GetLongVersion;

        names = target.Argument(
            "Enter the full name of the person to be greeted.",
            multipleValues: true);

        target.HelpOption("-? | -h | --help");

        target.OnExecute(() =>
            if (names?.Values.Any() == true)
                // show help if the required argument is missing
            return 0;

commandLineApplication.HelpOption("-? | -h | --help");
commandLineApplication.VersionOption("--version", GetShortVersion, GetLongVersion);

commandLineApplication.OnExecute(() =>
    // show help if root command
    return 0;


static void Greet(IEnumerable<string> values) => Console.WriteLine($"Hello {string.Join(" ", values)}!");

static string GetLongVersion() => "1.2.3";

static string GetShortVersion() => "v1.2.3+456abcd";

Play around

1. Get help on root

To know the available commands and options SampleCommandLine.exe --help

SampleCommandLine: greeting a fullname v1.2.3+456abcd

Usage: SampleCommandLine.exe [options] [command]

  -? | -h | --help  Show help information
  --version         Show version information

  hello  The hello command

Use "SampleCommandLine.exe [command] --help" for more information about a command.

2. Get help on hello command

To know the available arguments and options of a command SampleCommandLine.exe hello --help

Greeting a fullname v1.2.3+456abcd

Usage: SampleCommandLine.exe hello [arguments] [options]

  fullname  Enter the full name of the person to be greeted.

  -? | -h | --help  Show help information

3. Greeting a fullname

Command line SampleCommandLine.exe hello John Doe

Hello John Doe!

4. Check version

Command line SampleCommandLine.exe --version

SampleCommandLine: greeting a fullname

Project origin and status

This repos a fork of Microsoft.Extensions.CommandLineUtils. Microsoft announces discontinue support the library. You may check this repos if prefer the more enrich features.

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 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.1
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen 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.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0-a1.2 198 10/8/2022