I use Apache Commons CLI for parsing command line arguments.
I am looking for a way to display multiple argument value names in the help. Here is an example for one argument of the option "startimport":
Option startimport = OptionBuilder
.withArgName("environment")
.hasArg()
.withDescription(
"Description")
.create("startimport");
When I use -help it prints out:
-startimport <environment> Description
Thatfs fine. But what if I want to use two arguments?
Option startimport = OptionBuilder
.withArgName("firstArg secondArg")
.hasArgs(2)
.withDescription("Description")
.create("startimport ");
Parsing the two arguments is not the problem but I want the following output in the "-help":
startimport <firstArg> <secondArg> Description
But currently I would just get:
startimport <firstArg secondArg> Description
Is there a proper solution for that problem?
I used a naughty way to solve this problem.
OptionBuilder.hasArgs(3);
OptionBuilder.withArgName("hostname> <community> <oid");
OptionBuilder.withDescription("spans switch topology. Mutually exclusive with -s");
Option my_a = OptionBuilder.create("a");
It appears correctly in the help now. Though I am not sure if this has consequences though.