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 86 forks source link

Conditional parameters? #92

Closed ricebus closed 6 years ago

ricebus commented 6 years ago

Hey,

Is there a way to have conditional params?

I want to be able to do something like myapp.exe option1 --arg1 .. --arg 2 (where arg1 is required for example) or myapp.exe option2 --arg3 .. --arg 4 (where arg3 is required for example)

Thanks in advance

siywilliams commented 6 years ago

Hi @ricebus

Not sure I follow entirely but all are optional by default. You can specify required options using .Required() when setting up the option.

If you have specified some options as required and they are not found in the specified args then p.Parse(args).HasErrors will be true

ricebus commented 6 years ago

Thanks for the quick reply.

I want to have args1 as Required only if option1 is set. and args2 required if option2 is set. I can put them all under optional but that's not the wanted functionality.

The only work around I found is to first check args[0] "manually" by myself and then to build a different fclp args class..

siywilliams commented 6 years ago

Unfortunately the library isn't quite that advanced as you've discovered. You'll have to use your workaround for the foreseeable future as the library would need a bit of work to support behaviour such as that.

ricebus commented 6 years ago

Thanks for the quick reply 🤕