Bax
Bax

Reputation: 4466

commons-cli dependent arguments

I use apache commons-cli for a command line tool. I have pairs of dependent arguments, e.g argument B makes sense only if argument A is present. That will have 2 benefits : automatic warning/error and a more usefull usage statment . Does commons-cli support it ?

Upvotes: 7

Views: 1728

Answers (1)

Joe Casadonte
Joe Casadonte

Reputation: 16859

It does not; you have to enforce such things manually. CLI has OptionGroups, but they are purely mutually exclusive options, not dependent options. See JavaDoc for Option, OptionBuilder (which I highly recommend using) and the previously mentioned OptionGroup.

Upvotes: 6

Related Questions