in src/main/java/org/apache/sling/launchpad/app/Main.java [631:682]
static Map<String, String> parseCommandLine(String... args) {
Map<String, String> commandLine = new HashMap<String, String>();
boolean readUnparsed = false;
for (int argc = 0; args != null && argc < args.length; argc++) {
String arg = args[argc];
if (readUnparsed) {
commandLine.put(arg, arg);
} else if (arg.startsWith("-")) {
if (arg.length() == 1) {
readUnparsed = true;
} else {
String key = String.valueOf(arg.charAt(1));
if (arg.length() > 2) {
final String val;
final int indexOfEq = arg.indexOf('=');
if (indexOfEq != -1) {
//Handle case -Da=b
key = arg.substring(1, indexOfEq);
val = arg.substring(indexOfEq + 1);
} else {
val = arg.substring(2);
}
commandLine.put(key, val);
} else {
argc++;
if (argc < args.length
&& (args[argc].equals("-") || !args[argc].startsWith("-"))) {
String val = args[argc];
//Special handling for -D a=b
if(key.equals("D")){
final int indexOfEq = val.indexOf('=');
if (indexOfEq != -1) {
//Handle case -D a=b. Add key as Da
key = "D" + val.substring(0, indexOfEq);
val = val.substring(indexOfEq + 1);
}
}
commandLine.put(key, val);
} else {
commandLine.put(key, key);
argc--;
}
}
}
} else {
commandLine.put(arg, arg);
}
}
return commandLine;
}