public boolean getOptionalBooleanValue(boolean defaultValue) throws OptionsException {
        if (lastOptionValue != null) {
            // --option=value form
            String stringValue = lastOptionValue;
            lastOptionValue = null;
            if ("true".equals(stringValue)) {
                return true;
            } else if ("false".equals(stringValue)) {
                return false;
            }
            throw new OptionsException(
                    "Unsupported value for " + lastOptionOriginalForm + ": " + stringValue
                            + ". Only true or false supported.");
        }

        // --option (true|false) form OR just --option
        if (index >= params.length) {
            return defaultValue;
        }

        String stringValue = params[index];
        if ("true".equals(stringValue)) {
            index++;
            return true;
        } else if ("false".equals(stringValue)) {
            index++;
            return false;
        } else {
            return defaultValue;
        }
    }
Gets the value of the current boolean option. Boolean options are not required to have
explicitly specified values.
cli/src/main/java/com/mcxiaoke/packer/cli/Options.java