1

I have a very basic question, below is my Options class. I need to establish an OR relation between j and f flags i.e anyone should be mandatory to be passed.

        [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; }

Here what I need is, if j is not passed in the argument then f should be mandatory to pass or if f is not passed in the argument then j should be mandatory to pass. How can I achieve this ?

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86

1 Answers1

1

Looks like Group does the trick for you.

        [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; }