Skip to content

A .NET Standard library built for simple and accessible command line argument parsing, manual instructions and validation.

License

Notifications You must be signed in to change notification settings

WilliamRagstad/ArgumentsUtil

Repository files navigation

ArgumentsUtil
Nuget GitHub release (latest by date) Nuget

ArgumentsUtil

A .NET Standard library built for simple and accessible command line argument parsing, manual instructions and validation.

Usage

Examples

1. Static Manual

Source code:

using System;
using System.Collections.Generic;
using ArgumentsUtil;

namespace ConsoleAppTesting
{
    class Program
    {
        static void Main(string[] args)
        {
            Arguments a = Arguments.Parse(args);

            ArgumentsTemplate at = new ArgumentsTemplate( // This will setup the general structure of our manual
                new List<ArgumentOption>
                {
                    new ArgumentOption("v", "verbose", "Toggle verbose mode.", new List<ArgumentParameter> {
                        new ArgumentParameter("mode", typeof(bool), "", true)
                    }),
                    new ArgumentOption("e", null, "Use encoding mode to encode a file.", new List<ArgumentParameter> {
                        new ArgumentParameter("lsb", typeof(int))
                    }),
                    new ArgumentOption("e", null, "Use extended encoding with specified filepath and output.", new List<ArgumentParameter> {
                        new ArgumentParameter("file", typeof(string)),
                        new ArgumentParameter("out", typeof(string)),
                        new ArgumentParameter("debug", typeof(bool), "", true)
                    })
                },
                false,
                new List<ArgumentCommand> {
                    new ArgumentCommand("encode", "Select mode to encoding. This will encode a message inside the selected file.")
                },
                true,
                new List<ArgumentText> {
                    new ArgumentText("Custom title:", new[] {"This text is completely customizable! And you can write anything you want here, isn't that amazing!!!"})
                },
                "My Custom Console App",
                (char)KeySelector.CrossPlatformCompatible
            );

            at.ShowManual(HelpFormatting.None);

            Console.Read();
        }
    }
}

Result:

Output

About

A .NET Standard library built for simple and accessible command line argument parsing, manual instructions and validation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages