Skip to content

Ackara/NShellit

Repository files navigation

NShellit

NuGet NuGet

What is NShellit?

NShellit is a command-line parser inspired by powershell. Powershell has one of the best argument convention around, so why not incorporate it into console applications.

Where can I get?

NShellit is available at nuget.org.

How it works?

First you will need to create a simple class that will store the options for your command, and decorate them with the following Attributes.

class CoolCommand : ICommand
{
    [Required, Parameter]
    public string SomeString { get; set; }
    
    [Parameter]
    public int SomeNumber { get; set; }
    
    [Parameter("s", "enabale")]
    public bool SomeSwitch { get; set; }
    
    int Execute() { ... }
}

Next in your Program.cs file add the following.

var parser = Acklann.NShellit.Parser.MapResults(args, typeof(CoolCommand));
/// OR EVEN BETTER
/// var parser = Acklann.NShellit.Parser.MapResults(args, allCommandTypes);

if (parser.HasResult)
{
    var command = parser.GetResult<ICommand>();
    return command.Execute();
}
else return parser.PrintUsage();

About

A .netstandard command-line parser and powershell module generator.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published