MiniCommandLineParser 1.0.1.1

dotnet add package MiniCommandLineParser --version 1.0.1.1
                    
NuGet\Install-Package MiniCommandLineParser -Version 1.0.1.1
                    
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="MiniCommandLineParser" Version="1.0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MiniCommandLineParser" Version="1.0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="MiniCommandLineParser" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MiniCommandLineParser --version 1.0.1.1
                    
#r "nuget: MiniCommandLineParser, 1.0.1.1"
                    
#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.
#:package MiniCommandLineParser@1.0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MiniCommandLineParser&version=1.0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=MiniCommandLineParser&version=1.0.1.1
                    
Install as a Cake Tool

MiniCommandLineParser

A simple, lightweight, and dependency-free command-line parsing library for .NET.

âœĻ Features

  • ðŸŠķ Lightweight - Minimal footprint, no external dependencies
  • ðŸŽŊ Simple API - Intuitive attribute-based configuration
  • ðŸ“Ķ Multi-target - Supports .NET 6/7/8/9 and .NET Standard 2.1
  • 🔄 Bidirectional - Parse arguments to objects AND format objects back to command-line strings
  • 📝 Auto Help Text - Built-in help text generation
  • 🔧 Flexible - Supports short/long options, arrays, enums, flags, and more
  • 📍 Positional Arguments - Support index-based positional parameters (e.g., app clone http://...)
  • ✂ïļ Custom Separators - Split array values with custom separators (e.g., --tags=a;b;c)

ðŸ“Ĩ Installation

dotnet add package MiniCommandLineParser

🚀 Quick Start

1. Define Your Options Class

using MiniCommandLineParser;

public class Options
{
    [Option('i', "input", Required = true, HelpText = "Input file path")]
    public string InputFile { get; set; }

    [Option('o', "output", HelpText = "Output file path")]
    public string OutputFile { get; set; }

    [Option('v', "verbose", HelpText = "Enable verbose output")]
    public bool Verbose { get; set; }

    [Option("count", HelpText = "Number of iterations")]
    public int Count { get; set; } = 1;

    [Option("tags", HelpText = "List of tags")]
    public List<string> Tags { get; set; }
}

2. Parse Command-Line Arguments

var result = Parser.Default.Parse<Options>(args);

if (result.Result == ParserResultType.Parsed)
{
    var options = result.Value;
    Console.WriteLine($"Input: {options.InputFile}");
}
else
{
    Console.WriteLine(result.ErrorMessage);
}

📍 Positional Arguments

Support CLI-style positional parameters without option names:

public class CloneOptions
{
    [Option("command", Index = 0, HelpText = "Command name")]
    public string Command { get; set; }

    [Option("url", Index = 1, HelpText = "Repository URL")]
    public string Url { get; set; }

    [Option('v', "verbose", HelpText = "Verbose output")]
    public bool Verbose { get; set; }
}

// Parse: myapp clone https://github.com/user/repo --verbose
// Result: Command="clone", Url="https://github.com/user/repo", Verbose=true

✂ïļ Custom Array Separators

Split array values using custom separators:

public class BuildOptions
{
    // Default separator is ';'
    [Option("tags", Separator = ';', HelpText = "Tags separated by semicolon")]
    public List<string> Tags { get; set; }

    // Custom separator
    [Option("ids", Separator = ',', HelpText = "IDs separated by comma")]
    public int[] Ids { get; set; }
}

// Parse: --tags=dev;test;prod --ids=1,2,3
// Result: Tags=["dev","test","prod"], Ids=[1,2,3]

📖 Supported Argument Formats

# Short options
-v -i input.txt

# Long options
--verbose --input input.txt

# Equals syntax
--input=input.txt --config="key=value"

# Boolean options (all equivalent)
--verbose
--verbose=true
--verbose true

# Quoted values (with spaces)
--output "my output file.txt"

# Array values (space-separated)
--tags tag1 tag2 tag3

# Array values (with separator)
--tags=tag1;tag2;tag3

# Positional arguments
clone https://example.com --verbose

# Flags enum
--flags Flag1 Flag2 Flag3

🔄 Format Object to Command Line

Convert objects back to command-line strings with flexible formatting options:

var options = new Options { InputFile = "test.txt", Verbose = true };

// Full output (all options with space syntax)
string cmdLine = Parser.FormatCommandLine(options, CommandLineFormatMethod.Complete);
// Output: --input test.txt --verbose True --count 1

// Simplified output (only non-default values)
string simplified = Parser.FormatCommandLine(options, CommandLineFormatMethod.Simplify);
// Output: --input test.txt --verbose True

// Equal sign style (use = between option and value)
string equalStyle = Parser.FormatCommandLine(options, CommandLineFormatMethod.EqualSignStyle);
// Output: --input=test.txt --verbose=True --count=1

// Combine flags: Simplify + EqualSignStyle
string combined = Parser.FormatCommandLine(options, 
    CommandLineFormatMethod.Simplify | CommandLineFormatMethod.EqualSignStyle);
// Output: --input=test.txt --verbose=True

Array Formatting

Arrays are formatted differently based on the style:

public class BuildOptions
{
    [Option("tags", Separator = ';')]
    public List<string> Tags { get; set; }
    
    [Option("ids", Separator = ',')]
    public int[] Ids { get; set; }
}

var options = new BuildOptions 
{ 
    Tags = ["dev", "test", "prod"],
    Ids = [1, 2, 3]
};

// Space-separated style (Complete/Simplify without EqualSignStyle)
Parser.FormatCommandLine(options, CommandLineFormatMethod.Complete);
// Output: --tags dev test prod --ids 1 2 3

// Equal sign style - arrays use separator automatically
Parser.FormatCommandLine(options, CommandLineFormatMethod.EqualSignStyle);
// Output: --tags=dev;test;prod --ids=1,2,3

Format Method Flags

Flag Description
None Default space-separated style
Complete Output all options including defaults
Simplify Only output non-default values
EqualSignStyle Use --option=value syntax, arrays use separator

Flags can be combined using | operator for flexible output formatting.

📝 Auto-Generate Help Text

var helpText = Parser.GetHelpText(new Options());
Console.WriteLine(helpText);

⚙ïļ Parser Settings

var parser = new Parser(new ParserSettings
{
    CaseSensitive = false,          // Case-insensitive matching (default)
    IgnoreUnknownArguments = true   // Ignore unknown arguments (default)
});

📄 License

MIT License - see GitHub Repository for details.

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 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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • 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
1.0.1.1 30 1/22/2026
1.0.0.1 36 1/20/2026