mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
17.32.2014 a70b2bcac49f3c36b89ae6fd7e2e9b4dd052326f
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
@@ -130,6 +130,9 @@
    /** Indicates whether the version argument was provided. */
    private boolean versionPresent;
    /** The handler to call to print the product version. */
    private VersionHandler versionHandler;
    /**
     * The set of arguments defined for this parser, referenced by short ID.
     */
@@ -958,11 +961,12 @@
                        // usage information.
                        writeUsageToOutputStream();
                        return;
                    } else if (OPTION_LONG_PRODUCT_VERSION.equals(argName)) {
                    } else if (versionHandler != null && OPTION_LONG_PRODUCT_VERSION.equals(argName)) {
                        // "--version" will always be interpreted as requesting
                        // version information.
                        usageOrVersionDisplayed = true;
                        versionPresent = true;
                        versionHandler.printVersion();
                        return;
                    } else {
                        // There is no such argument registered.
@@ -1035,13 +1039,14 @@
                    if (argCharacter == '?') {
                        writeUsageToOutputStream();
                        return;
                    } else if (argCharacter == OPTION_SHORT_PRODUCT_VERSION
                    } else if (versionHandler != null && argCharacter == OPTION_SHORT_PRODUCT_VERSION
                            && !shortIDMap.containsKey(OPTION_SHORT_PRODUCT_VERSION)) {
                        // "-V" will always be interpreted as requesting
                        // version information except if it's already defined
                        // (e.g in ldap tools).
                        usageOrVersionDisplayed = true;
                        versionPresent = true;
                        versionHandler.printVersion();
                        return;
                    } else {
                        // There is no such argument registered.
@@ -1313,6 +1318,16 @@
    }
    /**
     * Sets the version handler which will be used to display the product version.
     *
     * @param handler
     *            The version handler.
     */
    public void setVersionHandler(final VersionHandler handler) {
        versionHandler = handler;
    }
    /**
     * Indicates whether the version or the usage information has been displayed
     * to the end user either by an explicit argument like "-H" or "--help", or
     * by a built-in argument like "-?".