如何在两个参数之间有 OR 关系的选项
How to have Options with OR relations between 2 arguments
我有一个非常基本的问题,下面是我的选项 class。我需要在 j 和 f 标志之间建立一个或关系,即任何人都应该被强制通过。
[Option('j', "jsonfile", Required = true, HelpText = "Path to json file")]
public string JsonFilePath { get; set; }
[Option('f', "jsonfolder", Required = true, HelpText = "Path to json directory")]
public string JsonFolder { get; set; }
[Option('t', "targetpath", Required = true, HelpText = "Target folder")]
public string TargetFolder { get; set; }
我需要的是,如果参数中没有传递 j 那么 f 应该是强制传递的,或者如果 f 没有在参数中传递,那么 j 应该是强制传递的。我怎样才能做到这一点?
看来 Group 可以为您解决问题。
[Option('j', "jsonfile", Group= "json", HelpText = "Path to json file")]
public string JsonFilePath { get; set; }
[Option('f', "jsonfolder", Group= "json", HelpText = "Path to json directory")]
public string JsonFolder { get; set; }
[Option('t', "targetpath", Required = true, HelpText = "Target folder")]
public string TargetFolder { get; set; }
我有一个非常基本的问题,下面是我的选项 class。我需要在 j 和 f 标志之间建立一个或关系,即任何人都应该被强制通过。
[Option('j', "jsonfile", Required = true, HelpText = "Path to json file")]
public string JsonFilePath { get; set; }
[Option('f', "jsonfolder", Required = true, HelpText = "Path to json directory")]
public string JsonFolder { get; set; }
[Option('t', "targetpath", Required = true, HelpText = "Target folder")]
public string TargetFolder { get; set; }
我需要的是,如果参数中没有传递 j 那么 f 应该是强制传递的,或者如果 f 没有在参数中传递,那么 j 应该是强制传递的。我怎样才能做到这一点?
看来 Group 可以为您解决问题。
[Option('j', "jsonfile", Group= "json", HelpText = "Path to json file")]
public string JsonFilePath { get; set; }
[Option('f', "jsonfolder", Group= "json", HelpText = "Path to json directory")]
public string JsonFolder { get; set; }
[Option('t', "targetpath", Required = true, HelpText = "Target folder")]
public string TargetFolder { get; set; }