LeForg.Clarp 1.2.1

dotnet add package LeForg.Clarp --version 1.2.1
                    
NuGet\Install-Package LeForg.Clarp -Version 1.2.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="LeForg.Clarp" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LeForg.Clarp" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="LeForg.Clarp" />
                    
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 LeForg.Clarp --version 1.2.1
                    
#r "nuget: LeForg.Clarp, 1.2.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 LeForg.Clarp@1.2.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=LeForg.Clarp&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=LeForg.Clarp&version=1.2.1
                    
Install as a Cake Tool

Command-Line Arguments Parser

The goal of this project is to provide a simple way to parse command line arguments. It should parse the arguments in a way that is easy to use and understand and leave the implementation of commands, subcommands and options/flags to the implementer.

Installation

TODO

Usage

using LeForg.Clarp.ArgParser;

class Program {
    static void Main(string[] args) {
        ArgParser p = new();

        Console.WriteLine(p.ToString());
    }
}

Format

echo "This is Piped Data" | command arg1 -flag1 arg2 --option1 "option1 value" -flag2  -- passthrough arguments "are useful"

Arguments

Arguments are the values that are passed to the command, they are the values that are not preceded by a flag or option and are not the passthrough arguments.

Flags

Flags are simple boolean values, they are either present or not. They are preceded by a single dash -. They are used to indicate the presence of a certain feature or option. If you want to pass a value to a flag, you should use an option instead.

Options

Options are key-value pairs. They are preceded by two dashes --. They are used to pass a value to a certain feature or option. If the value contains spaces, it should be enclosed in quotes ("/\/') and will end at the next un-escaped quote. If the value is not enclosed in quotes, it will end at the next space.

Passthrough Arguments

Passthrough arguments are the values that are passed after a --. They are not processed by the parser and will be returned as a list of strings for the implementer to use.

Piped Data

Piped data is the data that is passed to the command through a pipe (|). It is not processed by the parser and stored in this.pipe.

Testing

Running make test will test ArgParser with the arguments defined here. It should say all tests have passed (you can find the tests in ./example/Program.cs). There is a bug where MSTest cant see command line args passed to it, so the tests are run in the example project.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.2.1 236 3/26/2025
0.1.0 531 3/26/2025

Updated version to match ts