private static void parseCommandLine()

in src/main/java/org/apache/sling/launchpad/base/app/MainDelegate.java [222:296]


    private static void parseCommandLine(Map<String, String> args,
            Map<String, String> props) {

        /*
         * NOTE: We expect command line args to be suitable to use as
         * properties to launch Sling. Any standalone Java application
         * command line args have to be translated into Sling launcher
         * properties by the Main class. For deployment of the Launchpad
         * JAR into older launchers we keep converting existing command
         * line args for now. New command line arguments must solely be
         * known and converted in the Main class and not here.
         */

        for (Entry<String, String> arg : args.entrySet()) {
            if (arg.getKey().length() == 1) {
                String value = arg.getValue();
                switch (arg.getKey().charAt(0)) {
                    case 'l':
                        if (value == arg.getKey()) {
                            terminate("Missing log level value", 1);
                            continue;
                        }
                        props.put(PROP_LOG_LEVEL, value);
                        break;

                    case 'f':
                        if (value == arg.getKey()) {
                            terminate("Missing log file value", 1);
                            continue;
                        } else if ("-".equals(value)) {
                            value = "";
                        }
                        props.put(PROP_LOG_FILE, value);
                        break;

                    case 'c':
                        if (value == arg.getKey()) {
                            terminate("Missing directory value", 1);
                            continue;
                        }
                        props.put(SharedConstants.SLING_HOME, value);
                        break;

                    case 'p':
                        if (value == arg.getKey()) {
                            terminate("Missing port value", 1);
                            continue;
                        }
                        try {
                            // just to verify it is a number
                            Integer.parseInt(value);
                            props.put(PROP_PORT, value);
                        } catch (RuntimeException e) {
                            terminate("Bad port: " + value, 1);
                        }
                        break;

                    case 'a':
                        if (value == arg.getKey()) {
                            terminate("Missing address value", 1);
                            continue;
                        }
                        info("Setting the address to bind to is not supported, binding to 0.0.0.0", null);
                        break;

                    default:
                        terminate("Unrecognized option " + arg.getKey(), 1);
                        break;
                }
            } else {
                info("Setting " + arg.getKey() + "=" + arg.getValue(), null);
                props.put(arg.getKey(), arg.getValue());
            }
        }
    }