EasyArguments 1.0.8
See the version list below for details.
dotnet add package EasyArguments --version 1.0.8
NuGet\Install-Package EasyArguments -Version 1.0.8
<PackageReference Include="EasyArguments" Version="1.0.8" />
<PackageVersion Include="EasyArguments" Version="1.0.8" />
<PackageReference Include="EasyArguments" />
paket add EasyArguments --version 1.0.8
#r "nuget: EasyArguments, 1.0.8"
#:package EasyArguments@1.0.8
#addin nuget:?package=EasyArguments&version=1.0.8
#tool nuget:?package=EasyArguments&version=1.0.8
<div align="center">
EasyArguments
EasyArguments is a lightweight .NET library that simplifies the process of parsing command-line arguments into strongly-typed objects.
</div>
Table of Contents
About the project
Parsing command-line arguments in .NET applications can often be cumbersome and error-prone, requiring repetitive code to handle different argument formats, validations, and help documentation. EasyArguments streamlines this process by providing a simple, declarative way to map command-line arguments to strongly-typed objects with minimal boilerplate code.
Key Features ✨
Attribute-Based Configuration: Define arguments using [Argument] attributes directly on your model properties.
Strongly-Typed Parsing: Automatically convert arguments to their correct data types (e.g.,
string
,bool
,int
).Boolean Flags and Inversion: Support for flags like
--verbose
and inverted options like--no-gui
with theInvertBoolean
parameter.Automatic Help Generation: Built-in
--help
command generates a formatted help screen based on your argument definitions.Automatic methods execution Automatically execute any static method that you want while parsing!
Validation: Mark arguments as required, and let the library handle missing or invalid inputs gracefully.
Lightweight: Minimal dependencies and low overhead, designed for performance and simplicity.
Why EasyArguments? 🚀
Reduce Boilerplate: Eliminate manual parsing loops and condition checks.
Intuitive Syntax: Declare arguments naturally with C# properties and attributes.
Flexible: Supports both short (-n) and long (--name) argument formats.
Error Handling: Clear exception messages guide users when inputs are missing or invalid.
Ideal for developers who want to build robust CLI tools, EasyArguments empowers you to define, parse, and validate arguments in minutes. Check out the Basic Usage Example to get started or explore the Full Documentation for advanced features!
Installation 👌
You can install EasyArguments via terminal:
dotnet add package EasyArguments
Or via nuget package manager on Visual Studio:
Basic Usage Example 📝
This is a basic example. For a comprehensive guide, check out the Full Documentation 📚.
1) Setup an argument class
using EasyArguments;
using EasyArguments.Attributes;
using System;
// The 'Name' parameter specifies the name of the application or command,
// which will be displayed when the user invokes the --help option.
[ArgumentsController(Name = "you_app.exe")]
public class MyArgs
{
[Argument("-n", "--name", "Specifies the user name", Required = true)]
public string? Name { get; set; }
[Argument("-v", "--verbose", "Enable verbose output", Required = false)]
public bool? Verbose { get; set; }
[Argument(null, "--no-gui", "Disable the GUI", InvertBoolean = true)]
public bool GuiEnabled { get; set; }
}
2) Create an instance of ArgumentsController
using EasyArguments;
public class Program
{
static void Main(string[] args)
{
try
{
// Instantiate a controller for your argument class
var controller = new ArgumentsController<MyArgs>(args);
// Parse the given args
MyArgs parsed = controller.Parse();
// Now you can use properties as you want:
Console.WriteLine($"Name: {parsed.Name}");
Console.WriteLine($"Verbose: {parsed.Verbose}");
Console.WriteLine($"GUI enabled: {parsed.GuiEnabled}");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
Contribution ❤️
Contributions are welcome!
If you have ideas to improve EasyArguments feel free to open an issue.
License 🪪
This project is licensed under the GPLv3 License. See the LICENSE file for details.
Product | Versions 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. |
-
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.