C# CommandLineParser

下载:

https://www.nuget.org/packages/CommandLineParser/

使用:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class Options
{
[Option('i', "input", Required = true, HelpText = "help text")]
public string input { get; set; }

[Option('o', "output", Required = true, HelpText = "help text")]
public string output { get; set; }
}
static void Main(string[] args)
{
Parser.Default.ParseArguments<Options>(args)
.WithNotParsed(errs => HandleErrors(errs))
.WithParsed(opts => RunOptions(opts));
}