4

I found a command line utility in our code base where the author had written a homebrew command line parser, which involved more code than the utility itself did. I decided to switch it to using Apache CLI and things are almost working.

The utility makes use of trailing args, so it'd look something like this:

util --argA=1 --argB=2 foo blah blarg

where "foo", "blah", and "blarg" are used as an argument.

Is there a way to handle this situation? I'd rather not (and might not be empowered to) change the command line signature of this utility.

Sahil Muthoo
  • 12,033
  • 2
  • 29
  • 38
geoffjentry
  • 4,674
  • 3
  • 31
  • 37
  • Disregard - I just stumbled across the getArgs() method from the CommandLine class, which appears to be exactly what I'm looking for. – geoffjentry Sep 16 '11 at 20:07

1 Answers1

6

Look at CommandLine.getArgList() or CommandLine.getArgs(), both return the "remaining" items from the commandline which were not handled by the options.

See CommandLine javadocs for details.

Gray
  • 115,027
  • 24
  • 293
  • 354
centic
  • 15,565
  • 9
  • 68
  • 125