按需输出使用 DragonFruit 的帮助

5 c# command-line-arguments .net-core dragonfruit

我正在使用System.CommandLine.DragonFruit来处理命令行参数。如果可执行文件中发生错误,我想输出与“--help”选项自动输出相同的帮助文本。有没有我可以调用的方法来输出此帮助文本?

Kul*_*gin 6

几个月前我需要完全相同的东西,不幸的是找不到内置的方法来做到这一点。

我发现的解决方法是使用ExecuteAssembly带有--help参数的DragonFruit 的辅助方法来调用自动生成的类。

无论如何,这就是 DragonFruit 在幕后所做的。

System.CommandLine.DragonFruit.CommandLine.ExecuteAssembly(typeof(AutoGeneratedProgram).Assembly, new string[] { "--help" }, "");
Run Code Online (Sandbox Code Playgroud)