-
Notifications
You must be signed in to change notification settings - Fork 292
Mutually Exclusive Options
gsscoder edited this page Feb 27, 2013
·
17 revisions
You can define options that belong to set that are mutually exclusive. Suppose you've an utility that for both web and ftp servers.
Defining the options class as follows:
class Options
{
[Option(MutuallyExclusiveSet = "web")]
public string DocumentRoot { get; set; }
[Option(MutuallyExclusiveSet = "web")]
public bool EnableJavaScript { get; set; }
[Option(MutuallyExclusiveSet = "ftp")]
public string FtpDirectory { get; set; }
[Option("MutuallyExclusiveSet" = "ftp")
public bool AnonymousLogin { get; set; }
}
you group options in different set. In this way if you combine an ftp option with a web one, parsing will fail.
;; permitted
$ app --enablejavascript --documentroot ~/var/local/website
;; denied
$ app --anonymouslogin --enablejavascript
If you've various sets and and each set contains a good number of options, It's better to structure you're application with Verb Commands