我开始使用CommandLine Parser Library来获得一个既有GUI又有命令行执行的工具.通过命令行选项启动GUI.
因此,如果程序在命令行模式下执行,我希望有必要的选项.基本上,如果没有设置选项"Gui",我会要求选项1和选项2.
我试图将MutuallyExclusiveSet和Required属性结合起来,如下所示,但它没有像我想象的那样工作.我是否误解了"MutuallyExclusiveSet"的概念,或者只是误用了它?或者图书馆还没有支持?
public class CommandLineOptions : CommandLineOptionsBase
{
[Option(null, "gui", Required = false, HelpText = "Launch the GUI", MutuallyExclusiveSet = "Gui")]
public bool Gui { get; set; }
[Option(null, "opt1", HelpText = "Option 1", MutuallyExclusiveSet = "CommandLine", Required = true)]
public string Option1 { get; set; }
[Option(null, "opt2", HelpText = "Option 2", MutuallyExclusiveSet = "CommandLine", Required = true)]
public string Option2 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)