Commandlineutils

Command line parsing and utilities for .NET
Alternatives To Commandlineutils
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Marked29,367
3 days ago33otherJavaScript
A markdown parser and compiler. Built for speed.
Jc6,127
7 days ago90July 06, 202214mitPython
CLI tool and python library that converts the output of popular command-line tools, file-types, and common strings to JSON, YAML, or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.
Picocli4,1732092502 days ago78February 09, 2022108apache-2.0Java
Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
Dasel4,1297a day ago80August 24, 202229mitGo
Select, put and delete data from JSON, TOML, YAML, XML and CSV files with a single tool. Supports conversion between formats and can be used as a Go package.
Commandline3,9162,9564217 days ago97May 17, 2022280mitC#
The best C# command line parser that brings standardized *nix getopt style, for .NET. Includes F# support
Kingpin3,2963,3301,551a month ago55November 05, 201925mitGo
CONTRIBUTIONS ONLY: A Go (golang) command line and flag parser
Command Line Api3,02927105a day ago29February 17, 2022455mitC#
Command line parsing, invocation, and rendering of terminal output.
Cli112,578
2 days ago7March 27, 202285otherC++
CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.
Vue Styleguidist2,342126351a day ago359September 06, 202267mitTypeScript
Created from react styleguidist for Vue Components with a living style guide
Commandlineutils2,0402681072 months ago49December 27, 202113apache-2.0C#
Command line parsing and utilities for .NET
Alternatives To Commandlineutils
Select To Compare


Alternative Project Comparisons
Readme

CommandLineUtils

Build Status Code Coverage NuGet NuGet Downloads

This project helps you create command line applications using .NET. It simplifies parsing arguments provided on the command line, validating user inputs, and generating help text.

The roadmap for this project is pinned to the top of the issue list.

Usage

See documentation for API reference, samples, and tutorials. See also docs/samples/ for more examples, such as:

Installing the library

This project is available as a NuGet package.

$ dotnet add package McMaster.Extensions.CommandLineUtils

Code

CommandLineApplication is the main entry point for most console apps parsing. There are two primary ways to use this API, using the builder pattern and attributes.

Attribute API

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}!");
        }
    }
}

Builder API

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);

Utilities

The library also includes other utilities for interaction with the console. These include:

  • ArgumentEscaper - use to escape arguments when starting a new command line process.
     var args = new [] { "Arg1", "arg with space", "args ' with \" quotes" };
     Process.Start("echo", ArgumentEscaper.EscapeAndConcatenate(args));
    
  • Prompt - for getting feedback from users with a default answer. A few examples:
    // allows y/n responses, will return false by default in this case.
    // You may optionally change the prompt foreground and background color for
    // the message.
    Prompt.GetYesNo("Do you want to proceed?", false);
    
    // masks input as '*'
    Prompt.GetPassword("Password: ");
    
  • DotNetExe - finds the path to the dotnet.exe file used to start a .NET Core process
    Process.Start(DotNetExe.FullPathOrDefault(), "run");
    

And more! See the documentation for more API, such as IConsole, IReporter, and others.

Getting help

If you need help with this project, please ...

Project origin and status

This is a fork of Microsoft.Extensions.CommandLineUtils, which was completely abandoned by Microsoft. This project forked in 2017 and continued to make improvements. From 2017 to 2021, over 30 contributors added new features and fixed bugs. As of 2022, the project has entered maintenance mode, so no major changes are planned. See this issue for details on latest project status. This project is not abandoned -- I believe this library provides a stable API and rich feature set good enough for most developers to create command line apps in .NET -- but only the most critical of bugs will be fixed (such as security issues).

Popular Parser Projects
Popular Command Line Projects
Popular Data Processing Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
C Sharp
Command Line
Parsing
Builder