处理命令行main函数args参数
引用 System.CommandLine 库(需要显示预览版才能看到)
var fileOption = new Option<FileInfo?>(
name: "--file",
description: "The file to read and display on the console.");
var rootCommand = new RootCommand("Sample app for System.CommandLine");
rootCommand.AddOption(fileOption);
rootCommand.SetHandler((file) =>
{
ReadFile(file!);
},
fileOption);
return await rootCommand.InvokeAsync(args);