ArgumentBase 1.0.0
dotnet add package ArgumentBase --version 1.0.0
NuGet\Install-Package ArgumentBase -Version 1.0.0
<PackageReference Include="ArgumentBase" Version="1.0.0" />
paket add ArgumentBase --version 1.0.0
#r "nuget: ArgumentBase, 1.0.0"
// Install ArgumentBase as a Cake Addin #addin nuget:?package=ArgumentBase&version=1.0.0 // Install ArgumentBase as a Cake Tool #tool nuget:?package=ArgumentBase&version=1.0.0
ArgumentBase
This is a small library that will parse your command-line arguments for you in a pretty easy-to-use fashion. This library only exists because I wrote this code for a different project and then found myself copy-pasting it constantly. This is to ease my own suffering.
This is largely purpose-built for me, but feel free to use it. That's why it's here.
How to use
Import the package using your preferred method. Then, once it's installed, create a class like this:
public class YourArguments : ArgumentBase<YourArguments>
{
// Positional arguments are called "parameters." No prefix is necessary.
[IsParameter(1, "An example description for the parameter.")]
public string ExampleParameter { get; set; } // It must be a property with a set method or it won't be identified.
// Variables are formatted like this: "-var:3.14"
[IsVariable("var", "An example description for the variable.")]
public double ExampleVariable { get; set; } // Parameters and variables can be any object that derives from IParsable.
// Flags are formatted like this: "--flag"
[IsFlag("flag", "An example description for the flag.")]
public bool ExampleFlag { get; set; } // Flags, however, can only be booleans.
// Whenever a flag is included as an argument, its value is flipped.
}
Then, in your Main method, paste the following:
static void Main(string[] args)
{
YourArguments args = YourArguments.Parse(args);
}
That's it. Not too bad, right?
Product | Versions 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. net9.0 was computed. 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. |
-
net8.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.0.0 | 35 | 2/4/2025 |