Question: I'm new to Apache Commons CLI 1.5.0 and having trouble with the following problem. I need to create two options r and g. The r

I'm new to Apache Commons CLI 1.5.0 and having trouble with the following problem.

I need to create two options r and g. The r flag needs to take in two strings, old and new, and replaces the old string with the new string in a given input file. The g flag can only be used with the r flag and replaces all occurrences of the old with new.

So g flag is dependent on r and should error out when g is used without the r flag.

The syntax would look like this:

tool -r 123 345 -g

I'm a bit lost here. How do I configure commons-cli to handle the options above?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!