CommandLineUtils parses .NET arguments with attributes or a builder, and is in maintenance mode
Command line parsing and utilities for .NET
At a glance
- What is it?
- McMaster.Extensions.CommandLineUtils is a .NET library for parsing arguments, validating input and generating help text. It forked Microsoft's abandoned CommandLineUtils in 2017 and has been in maintenance mode since 2022.
- Who is it for?
- Use CommandLineUtils if you write .NET 8 or Framework 4.7.2 console tools and want attribute or builder parsing with prompts and argument escaping included, and you accept that only critical fixes will land. Look elsewhere if you need new features from the maintainer or a target framework below the supported floor.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 147 days ago.
- What is it written in?
- Mainly C#, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.
Star history
- natemcmaster/CommandLineUtils2,268 ★ · -6
| Repository | 2026-10-08 | 2026-11-25 |
|---|---|---|
| natemcmaster/CommandLineUtils | 2.3k | 2.3k |
-6 Stars in the last 48 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Attributes on properties, or a builder with Option objects: two ways into CommandLineApplication
CommandLineApplication is the entry point for most console apps built on this library, and it offers two styles. The attribute API turns a class into the command. Options are properties marked with [Option], and the framework calls OnExecute when parsing succeeds:
using System;
using McMaster.Extensions.CommandLineUtils;
public class Program
{
public static int Main(string[] args)
=> CommandLineApplication.Execute<Program>(args);
[Option(Description = "The subject")]
public string Subject { get; } = "world";
[Option(ShortName = "n")]
public int Count { get; } = 1;
private void OnExecute()
{
for (var i = 0; i < Count; i++)
{
Console.WriteLine($"Hello {Subject}!");
}
}
}Defaults are ordinary property initializers here: "world" and 1. The class is the whole definition, so help text and parsing rules sit next to the data they fill.
The README presents this as the attribute API and builds the whole example around three pieces: the Main method that calls CommandLineApplication.Execute<Program>(args), the two annotated properties, and the private OnExecute method. The option Subject carries a Description, which feeds help text. The option Count sets ShortName = "n", so it is reachable as -n. Nothing in the README says how the long name is derived from the property name, so check the documentation site before you rely on a particular spelling on the command line.
The builder API spells out every flag as a string and reads values back from Option objects
The second style builds the command at runtime. You declare options with a template string such as "-s|--subject <SUBJECT>", set DefaultValue on the returned object, and read results inside the OnExecute lambda:
using System;
using McMaster.Extensions.CommandLineUtils;
var app = new CommandLineApplication();
app.HelpOption();
var subject = app.Option("-s|--subject <SUBJECT>", "The subject", CommandOptionType.SingleValue);
subject.DefaultValue = "world";
var repeat = app.Option<int>("-n|--count <N>", "Repeat", CommandOptionType.SingleValue);
repeat.DefaultValue = 1;
app.OnExecute(() =>
{
for (var i = 0; i < repeat.ParsedValue; i++)
{
Console.WriteLine($"Hello {subject.Value()}!");
}
});
return app.Execute(args);Two details differ from the attribute version. Help is not automatic: the call to app.HelpOption() is what adds it. And the typed option, app.Option<int>, exposes ParsedValue, while the plain string option exposes Value(). Swapping them gives you a string where you wanted an int, or the reverse.
Installing from NuGet and checking the .NET floor of 8.0 and Framework 4.7.2
The package is McMaster.Extensions.CommandLineUtils on NuGet. One command adds it to a project:
$ dotnet add package McMaster.Extensions.CommandLineUtilsThe supported targets are two. dotnet 8.0 is the lowest Microsoft LTS version at the time of release. .NET Framework 4.7.2 is the lowest Framework version fully compatible with .NET Standard 2.0. The project does not compile for .NET Standard directly. Its stated reason is Microsoft guidance that .NET 5 and later reduce the need for it, and that two target frameworks seem sufficient, which avoids added complexity.
The consequence is a floor. A project on .NET 6 or 7, or on .NET Framework older than 4.7.2, falls outside the table, and the README does not say what happens there. Check your target framework before upgrading to the 5.x line. The latest releases are 5.1.0 on 2026-04-05, 5.0.1 on 2026-02-08 and 5.0.0 on 2026-01-21.
The README presents NuGet as the only distribution channel. There is no source build recipe in it, although the repository root holds CommandLineUtils.sln, Directory.Build.props and build.ps1 for anyone who wants to build it locally.
ArgumentEscaper, Prompt and DotNetExe handle the chores around the parser
Beyond parsing, the library ships helpers for console interaction. ArgumentEscaper escapes arguments when you start another process. The example passes three awkward strings, including one with a space and one with both quote styles, through EscapeAndConcatenate and hands the result to Process.Start("echo", ...). That solves quoting for the child process only. It does not parse anything.
Prompt asks the user a question with a default answer. Prompt.GetYesNo("Do you want to proceed?", false) accepts y or n and returns false when the user just presses enter. Prompt.GetPassword("Password: ") masks input as '*'. The README adds that you may change the prompt foreground and background color for the message.
DotNetExe finds the path to the dotnet.exe used to start a .NET Core process, so a tool can relaunch the SDK without guessing: Process.Start(DotNetExe.FullPathOrDefault(), "run");
IConsole and IReporter are named as further APIs, and their details live in the documentation site, not in the README. Neither is described further in the README, so open the documentation site before building on them.
The 2017 fork of Microsoft.Extensions.CommandLineUtils that Microsoft abandoned
This library is a fork of Microsoft.Extensions.CommandLineUtils from the aspnet/Common repository. The README links an issue that calls the Microsoft original completely abandoned, and the fork was made in 2017. From 2017 to 2021, over 30 contributors added features and fixed bugs.
The Microsoft original and this fork share a name stem but not a package id. Code written against the Microsoft namespace needs the McMaster.Extensions.CommandLineUtils package and its namespace instead.
The README says nothing about a migration guide or about which Microsoft APIs were renamed. If you carry a large codebase over, plan to compile and fix, and read CHANGELOG.md in the repository root, which is the only file listed that would record API changes between versions.
Maintenance mode since 2022, with critical bug fixes only
As of 2022 the project entered maintenance mode, and the README says no major changes are planned. It points to issue 485 for the current status. The author says the project is not abandoned and that the API is stable, but only the most critical bugs will be fixed, such as security issues.
The repository was last pushed on 2026-07-01 and is not archived, and the 5.0.0, 5.0.1 and 5.1.0 releases appeared between January and April of 2026. The README does not explain what those releases contain, so read CHANGELOG.md to find out whether 5.x changed any API before you upgrade from 4.x.
The practical limit is feature requests. If you need a capability the library lacks, such as a new validation type or an argument style, the stated policy is that only critical fixes land. The roadmap is pinned to the top of the issue list, and that is the place to see whether your need is already planned.
The README also lists the CI and code coverage badges at the top, which point at GitHub Actions on the main branch and Codecov. They show build status, not API guarantees.
Where to get help: samples, the docs site and the question label
The README orders its help sources. First the documentation site at natemcmaster.github.io/CommandLineUtils, which holds API reference, samples and tutorials. Then the docs/samples/ folder in the repository. Then the issues labeled question, where many were answered already. Last, a Q&A forum such as StackOverflow.com.
The samples folder is the most concrete resource. It contains a hello world, an async console app, a subcommands example for structuring an app, one on defining options with attributes, interactive console prompts, and required options and arguments under validation. Match your need to one of those six before reading the API reference.
The repository also has a CLAUDE.md and a .claude/ directory next to CONTRIBUTING.md and CODE_OF_CONDUCT.md. The README does not explain them. The license is Apache-2.0, with LICENSE.txt and NOTICE.txt in the root.
Editorial conclusion
Use CommandLineUtils if you write .NET 8 or Framework 4.7.2 console tools and want attribute or builder parsing with prompts and argument escaping included, and you accept that only critical fixes will land. Look elsewhere if you need new features from the maintainer or a target framework below the supported floor. Before adopting, build the hello world sample from docs/samples/ against your own target framework and check CHANGELOG.md for the 5.x changes.
Frequently asked questions
What is CommandLineUtils for?
It helps you create command line applications with .NET by parsing arguments, validating user input and generating help text.
How do I install CommandLineUtils?
Run dotnet add package McMaster.Extensions.CommandLineUtils. The package is published on NuGet.
Is CommandLineUtils still maintained?
It has been in maintenance mode since 2022, so only critical bugs such as security issues are fixed. The repository was last pushed on 2026-07-01 and is not archived.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/natemcmaster-commandlineutils)Star history chart for your README
[](https://hysenlabs.com/projects/natemcmaster-commandlineutils)Was this useful?