MagnetArgs 0.3.0

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

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

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.


Quick Install

Choose the method of your convenience.

Package Manager:

PM> Install-Package MagnetArgs

.Net CLI:

> dotnet add package MagnetArgs

>> See more installation options


Quick Start

Step 1. Define your classes

It's as simple as define a class, extend from IronOre and define the Chunk attribute in the properties you want to map.

You can define an alias for your arguments.

Example:

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

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

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

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

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

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

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

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

Step 2. Magnetize 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"
};
var yourObject = new TypeObject();

Magnet.Attract(yourObject, inputArgs);

Step 3. Enjoy

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 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 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  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.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • net5.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 468 11/21/2023
0.6.2 286 11/19/2023
0.6.1 384 11/7/2023
0.4.0 778 7/9/2022
0.3.0 683 3/12/2021

Minor improvements.