MagnetArgs 0.6.2.13

dotnet add package MagnetArgs --version 0.6.2.13                
NuGet\Install-Package MagnetArgs -Version 0.6.2.13                
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="MagnetArgs" Version="0.6.2.13" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MagnetArgs --version 0.6.2.13                
#r "nuget: MagnetArgs, 0.6.2.13"                
#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 MagnetArgs as a Cake Addin
#addin nuget:?package=MagnetArgs&version=0.6.2.13

// Install MagnetArgs as a Cake Tool
#tool nuget:?package=MagnetArgs&version=0.6.2.13                

MagnetArgs

"Simple argument parser with magnetism"

MagnetArgs helps with the task of mapping arguments to objects. Accelerating the process of define option variables in console applications or map complex objects in a variety of scenarios.


Install

Choose the method of your convenience.

Package Manager:

PM> Install-Package MagnetArgs

.Net CLI:

> dotnet add package MagnetArgs

>> See more installation options

Basic Setup

Step 1. Define your classes

It's as simple as define a class, decorating with the [Magnetizable] attribute and decorating the properties you want to map with the [Argument] attribute.

You can define an alias for your arguments, set mapping rules and add parsing functions as you need.

Example:

[Magnetizable]
class TypeObject
{
    [Argument("string-value", Alias = "string")]
    public string StringValue { get; set; }

    [Argument("char-value", Alias = "char")]
    public char CharValue { get; set; }

    [Argument("integer-value", Alias = "int")]
    public int IntegerValue { get; set; }

    [Argument("long-value", Alias = "long")]
    public long LongValue { get; set; }

    [Argument("boolean-value", Alias = "bool")]
    public bool BooleanValue { get; set; }

    [Argument("float-value", Alias = "float")]
    public float FloatValue { get; set; }

    [Argument("double-value", Alias = "double")]
    public double DoubleValue { get; set; }

    [Argument("decimal-value", Alias = "decimal")]
    public decimal DecimalValue { get; set; }
}

Step 2. Attract All

With an instance of your object, you can magnetize and attract values. Provide the object and arguments to <Magnet.Attract>. They will be assigned automatically.

Example:

var inputArgs = new string[] {
    "-string", "This is an String",
    "-char", "C",
    "-int", "128",
    "-long", "128",
    "-bool", "true",
    "-float", "12.8",
    "-double", "12.8",
    "-decimal", "12.8"
};

// Get object from arguments
var yourObject = Magnet.Attract<TypeObject>(inputArgs);

// OR Send an object as reference
var yourObject = new TypeObject();
Magnet.Attract(inputArgs, yourObject);

Step 3. Use

Example:

// Fully Mapped Object
Console.WriteLine(yourObject.StringValue);
Console.WriteLine(yourObject.IntegerValue);
Console.WriteLine(yourObject.DoubleValue);
...

>> See more on Get Started


Project References

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  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.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MagnetArgs:

Package Downloads
EasyApp

A simple console framework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.6.2.13 502 11/21/2023
0.6.2 315 11/19/2023
0.6.1 414 11/7/2023
0.4.0 810 7/9/2022
0.3.0 726 3/12/2021

Adding net8.0 compatibility.