Production | CI |
---|---|
This is an extension to CommandLineParser project.
Create your options class
[Verb("add")]
internal class AddOptions
{
}
Create your command handler class
internal class AddCommand : Command<AddOptions>
{
public override async Task<int> ExecuteAsync(AddOptions options)
{
// do your magic here
// and return some value
}
}
Handle input arguments in Program.Main
class Program
{
public static async Task<int> Main(IEnumerable<string> args)
{
var commands = new ICommand[]
{
new AddCommand(),
// add your other commands here
};
return await Parser.Default.ParseArguments(args, commands)
.WithNotParsed(result =>
{
// handle error
})
.WithParsedAsync(commands);
}
}
Copyrights © Arkadiusz Zachert
This software is licensed based on MIT License