fclp / fluent-command-line-parser

A simple, strongly typed .NET C# command line parser library using a fluent easy to use interface
Other
530 stars 85 forks source link

Pass additional parameters into Required() for conditional requirements #111

Open SCLDGit opened 3 years ago

SCLDGit commented 3 years ago

It would be nice to be able to mark some additional into into the Required() field, such that a parameter is only required if some other criteria are met. An example would be only requiring a password to be input if a user name has also been used as an argument. Something like:

parser.Setup(p_arg => p_arg.UserName)
                .As('u', "user")
                .WithDescription("The user name to use for login.");

 parser.Setup(p_arg => p_arg.UserPassword)
                .As('p', "password")
                .WithDescription("The user password to use for login.")
                .Required(p_otherArgs => !string.IsNullOrWhitespace(p_otherArgs.UserName));