按需输出使用 DragonFruit 的帮助

Outputting help using DragonFruit on demand

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

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

我找到的解决方法是使用 DragonFruit 的辅助方法 ExecuteAssembly--help 参数来调用自动生成的 class。

这就是 DragonFruit 在幕后所做的事情。

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