You can access the passed properties by simply modifying the passed command-line options
--status p=11 --status s=22
or with your short syntax
-sp=11 -ss=22
In this case, you can access your properties simply using code
if (cmd.hasOption("status")) { Properties props = cmd.getOptionProperties("status"); System.out.println(props.getProperty("p")); System.out.println(props.getProperty("t")); }
If you need to strictly use syntax, you can manually parse property = value pairs. In this case, you must remove the .withValueSeparator () call, and then use
String [] propvalues = cmd.getOptionValues("status"); for (String propvalue : propvalues) { String [] values = propvalue.split("="); System.out.println(values[0] + " : " + values[1]); }
source share