(String arg, Iterator<String> iter, Map<String, OptArg> opts)
| 365 | } |
| 366 | |
| 367 | private static Object[] parseShortForm(String arg, Iterator<String> iter, Map<String, OptArg> opts) { |
| 368 | arg = arg.substring(1,arg.length()); |
| 369 | OptArg opt = opts.get(arg); |
| 370 | String param; |
| 371 | if(opt != null) { |
| 372 | // matched |
| 373 | iter.remove(); // remove option from args list |
| 374 | // |
| 375 | if(opt.argument != null) { |
| 376 | param = iter.next(); |
| 377 | iter.remove(); // remove option from args list |
| 378 | } else { |
| 379 | param = null; |
| 380 | } |
| 381 | } else { |
| 382 | throw new RuntimeException("unknown command-line option: -" + arg); |
| 383 | } |
| 384 | return new Object[] {opt,param}; |
| 385 | } |
| 386 | |
| 387 | public static void usage(PrintStream output, OptArg...options) { |
| 388 | // first, work out gap information |
no test coverage detected