Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.
/ ArgsParser Public archive

A recreation of the GNU arguments parser written in C#

License

Notifications You must be signed in to change notification settings

vlOd2/ArgsParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

ArgsParser

A recreation of the GNU arguments parser written in C#

Example

$ dotnet new console
<ItemGroup>
  <Reference Include="ArgsParser">
    <HintPath>ArgsParser.dll</HintPath>
  </Reference>
</ItemGroup>
using System;
using ArgsParserNS;

public class Program 
{
    public static void Main(string[] args)
    {
        ArgsParser argsParser = new ArgsParser();
        argsParser.RegisteredArguments.Add(new Argument {
            Name = "help",
            ShortName = "h"
        });
        FilledArgument[] parsedArgs = argsParser.ParseArguments(args);

        foreach (FilledArgument parsedArg in parsedArgs)
        {
            Console.WriteLine($"{parsedArg.Arg.Name} ({parsedArg.Arg.ShortName}): {parsedArg.Value}");
        }
    }
}
$ dotnet build
$ dotnet bin/Debug/net6.0/Example.dll --help
help (h):
$ dotnet bin/Debug/net6.0/Example.dll --help=AValue
help (h): AValue
$ dotnet bin/Debug/net6.0/Example.dll -h
help (h):
$ dotnet bin/Debug/net6.0/Example.dll -h=AValue
help (h): AValue