CliArgsParser 1.1.3

Suggested Alternatives

CodeOfChaos.CliArgsParser

There is a newer version of this package available.
See the version list below for details.
dotnet add package CliArgsParser --version 1.1.3                
NuGet\Install-Package CliArgsParser -Version 1.1.3                
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="CliArgsParser" Version="1.1.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CliArgsParser --version 1.1.3                
#r "nuget: CliArgsParser, 1.1.3"                
#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.
// Install CliArgsParser as a Cake Addin
#addin nuget:?package=CliArgsParser&version=1.1.3

// Install CliArgsParser as a Cake Tool
#tool nuget:?package=CliArgsParser&version=1.1.3                

CLI Args Parser

CLI Args Parser is a library which allows you to process command line arguments in an efficient and structured way. This is particularly useful in scenarios where your application has numerous command line options, or where commands themselves are complex and require arguments.

Features

Here are the key features of CLI Args Parser:

  • Command Declaration and Registration: Commands are declaratively defined within a class using the Command attribute. The class containing these commands is marked with the CommandAtlas attribute. This arrangement provides a well-structured, easy-to-maintain way of defining and locating command handling logic.
  • Asynchronous Command Execution: CLI Args Parser allows for asynchronous execution of commands. This can provide major performance benefits, especially when commands involve IO-bound operations.
  • Argument Mapping: CLI Args Parser allows property-based argument mapping. Properties of a class implementing the IParameters interface can be used as the target of argument mapping from command line input. Argument mapping is further simplified through the use of the AutoArgValue attribute which takes the argument name as a parameter.
  • Integration with Serilog: Logging is a vital aspect, especially in debugging scenarios. CLI Args Parser is designed with integration hooks for Serilog, allowing for robust logging during command and argument parsing. Default is set to Logger.None so you can enable the logger when needed.

Quick Start

Here's a basic example on how to get started with CLI Args Parser:

using CliArgsParser.Attributes;
using CliArgsParser.Contracts;

// Define a class for mapping arguments
public class ArgsTest : IParameters  {
    [AutoArgValue("name")]
    public string Name { get; set; } = "Default Name";
}

[CommandAtlas]
public class MyAppCommands{
    
    [Command("hello")]
    public void CommandHello() {
        Console.Writeline("Hello there!");    
        /* Or your command' implementation, without arguments, goes here... */
    }

    [Command<ArgsTest>("greet")]
    public void CommandGreet(ArgsTest argsTest)  {
        /* Or Your command implementation goes here... */
        Console.Writeline($"Hello there and welcome, {argsTest.Name}");  
    }
}

static class Program {    
    public static void Main(string[] args) {
        IParser parser = new ParserConfiguration()
            .RegisterAtlas(new MyAppCommands())
            .CreateArgsParser();
        
        parser.TryParse("greet --name=John");
    }
}
Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.1.2 152 8/27/2024 2.1.2 is deprecated because it is no longer maintained.
2.1.1 90 8/27/2024 2.1.1 is deprecated because it is no longer maintained.
2.0.0 87 8/27/2024 2.0.0 is deprecated because it is no longer maintained.
1.1.3 134 6/13/2024 1.1.3 is deprecated because it is no longer maintained.
1.1.2 94 6/8/2024 1.1.2 is deprecated because it is no longer maintained.
1.1.1 123 6/6/2024 1.1.1 is deprecated because it is no longer maintained.
1.1.0 95 6/6/2024 1.1.0 is deprecated because it is no longer maintained.
1.0.5 126 5/8/2024 1.0.5 is deprecated because it is no longer maintained.
1.0.4 102 5/6/2024 1.0.4 is deprecated because it is no longer maintained.
1.0.3 103 5/6/2024 1.0.3 is deprecated because it is no longer maintained.
1.0.2 105 5/6/2024 1.0.2 is deprecated because it is no longer maintained.
1.0.1 106 5/5/2024 1.0.1 is deprecated because it is no longer maintained.
1.0.0 97 5/5/2024 1.0.0 is deprecated because it is no longer maintained.
0.6.0-preview-202404091715 90 4/9/2024 0.6.0-preview-202404091715 is deprecated because it is no longer maintained.
0.6.0-preview-202404091708 79 4/9/2024 0.6.0-preview-202404091708 is deprecated because it is no longer maintained.
0.6.0-preview-202404091651 77 4/9/2024 0.6.0-preview-202404091651 is deprecated because it is no longer maintained.
0.5.6 114 2/19/2024 0.5.6 is deprecated because it is no longer maintained.
0.4.0 114 2/14/2024 0.4.0 is deprecated because it is no longer maintained.
0.3.1 118 2/7/2024 0.3.1 is deprecated because it is no longer maintained.
0.2.0 102 2/6/2024 0.2.0 is deprecated because it is no longer maintained.
0.1.8 101 2/6/2024 0.1.8 is deprecated because it is no longer maintained.
0.1.7 99 2/6/2024 0.1.7 is deprecated because it is no longer maintained.
0.1.6 96 2/6/2024 0.1.6 is deprecated because it is no longer maintained.
0.1.5 101 2/6/2024 0.1.5 is deprecated because it is no longer maintained.
0.1.3 103 2/5/2024 0.1.3 is deprecated because it is no longer maintained.