ghlaga
Last Updated: February 25, 2016
·
853
· alexanderbrevig
Feb007acc38e70d57f7b4c205f7e8b26

Enabling your C# methods to be CLI callable

I made a library that makes it easy to enable your static functions to be called through CLI https://github.com/AlexanderBrevig/LazyCLI

Easily install with NuGet using Package Manager Console:

PM> Install-Package LazyCLI

Give this class:

namespace CLI
{
    public static class Hello
    {
        [LazyCLI]
        public static void World(string msg)
        {
            Console.WriteLine("Hello World: " + msg);
        }
    }
}

You can call the World method using:

LazyCLI.CLI.HandleArgs(new string[] { "CLI", "Hello", "World", "This is pretty handy" });

Will print:

Hello World: This is pretty handy
Say Thanks
Respond