Antelcat.Parameterization 1.2.3

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

// Install Antelcat.Parameterization as a Cake Tool
#tool nuget:?package=Antelcat.Parameterization&version=1.2.3                

Antelcat.Parameterization: Effortless Command-Line Application Builder

English | 中文

Welcome to Antelcat.Parameterization, a powerful source generator designed to revolutionize the way you create command-line applications. This tool simplifies the process of building CLI applications by automatically generating parsing methods with just attribute marking on classes and methods.

Features

  • Attribute-Driven Development: Easily define commands and arguments using attributes.
  • Automatic Parsing: Automatically generates methods for parsing command-line arguments.
  • Custom Type Converter: Works well with System.ComponentModel.StringConverter.

Demo

The Demo Program implements a simple Docker application to show its features.

  1. Pull an Image:

    Command:

    > pull ubuntu
    

    Output:

    Pulling image ubuntu:latest...
    Successfully Pulled image ubuntu:latest
    

    In this example, a custom Image class is seamlessly converted from a string, thanks to the [TypeConverter(typeof(ImageConverter))] attribute applied to Image. Additionally, for locally use, the [Argument(Converter = typeof(ImageConverter))] Image image annotation allows the same seamless conversion.

  2. Run a Container:

    Command:

    > run ubuntu
    

    Output:

    ubuntu:latest ubuntu running
    

    This demonstrates how the default value for the name parameter is automatically used when it's not provided in the input.

  3. Display Container Statistics:

    Command:

    > ps
    

    Output:

    CONTAINER_ID    IMAGE           NAME    STATUS
    00a57dbe        ubuntu:latest   ubuntu  running
    
  4. Stop a Container and Run a New One:

    Commands:

    > stop
    > stop 00a57dbe
    > run --name "my container" --image kali
    

    Output:

    Argument "id" is not specified.
    Stopping container 00a57dbe...
    Pulling image kali:latest...
    Successfully Pulled image kali:latest
    kali:latest my container running
    

    This example highlights the use of named switches, allowing argument reordering. Additionally, it showcases how strings enclosed in "" are correctly parsed.

  5. Display Updated Container Statistics:

    Command:

    > ps --all
    

    Output:

    CONTAINER_ID    IMAGE           NAME          STATUS
    00a57dbe        ubuntu:latest   ubuntu        stopped
    0419fcea        kali:latest     my container  running
    

    First, Argument(FullName = "all") replaces the full name of the original showAll. Argument(ShortName = "a") means ps -a also works as same.

    Second, the effect of ArgumentAttribute.DefaultValue is evident. When a switch is used without an accompanying value, the ArgumentAttribute.DefaultValue is automatically converted and used to fill the argument, regardless of the default parameter value of bool showAll = false.

Installation

  • Via Nuget (✨Recommanded)

    Uploaded to Nuget. You can install via nuget CLI or your favorite IDE.

  • Via source code

    1. Clone or download zip of the source code.

    2. Reference Antelcat.Parameterization and Antelcat.Parameterization.SourceGenerators as follows.

      <ItemGroup>
          <ProjectReference Include="..\Antelcat.Parameterization\Antelcat.Parameterization.csproj"/>
          <ProjectReference Include="..\Antelcat.Parameterization.SourceGenerators\Antelcat.Parameterization.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
      </ItemGroup>
      

      NOTICE that OutputItemType="Analyzer" ReferenceOutputAssembly="false" is necessary because it is a Source Generator.

    3. Enjoy.

Contributing

We welcome contributions to this project! Whether it's reporting bugs, suggesting enhancements, or adding new features, your input is valuable to us.

TODO

  • Nuget package.
  • Multiple parameters, use T[].
  • Automatically generate help documents.
  • Check for excess parameters.
  • Parameter combination, e.g. -it will both open -i and -t.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.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.5 118 6/13/2024
1.2.4 210 12/23/2023
1.2.3 118 12/23/2023
1.2.2 139 12/10/2023
1.2.1 111 12/8/2023
1.2.0 128 12/8/2023
1.1.0 127 12/7/2023
1.0.1 140 11/29/2023
1.0.0 128 11/29/2023