With CommonsCli, how do I parse an Option which can occur several times and has a flexible number of values?
问题 In some legacy code I'm porting a diy-command-line parser to Apache CommonsCli. I can't break previously allowed+documented Options, and one of the Options is giving me trouble: The Option has either one or two args, and can be specified as many times as desired. Option: [-option arg1 [arg2]]+ I want the result as String[][] as following: cli -option a b -option c should result in [ [a, b], [c,] ] and cli -option a -option b c should result in [ [a,], [b, c] ] My code looks something like