From a70b2bcac49f3c36b89ae6fd7e2e9b4dd052326f Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Wed, 17 Dec 2014 11:32:30 +0000
Subject: [PATCH] OPENDJ-1656 (CR-5711) start-ds -V displays no information
---
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
index 43a7ca7..2f33aaf 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
+++ b/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 "-?".
--
Gitblit v1.10.0