From 6df6635f1250c399a2f39d87d0534301ce4c22d7 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Fri, 31 Aug 2007 15:43:58 +0000
Subject: [PATCH] Exposes the reversion functionality of the upgrader (issue 2169). Originally it was intended to be exposed as a new script but in order to avoid the negativity of having a command devoted to undoing the upgrade and to avoid more scripts in the top-level directory, I've exposed the functionality as 2 new options in the existing upgrade script. I will update the Wiki with documentation for these new options soon.
---
opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java b/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
index 3061c6e..3e83a4b 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
@@ -52,6 +52,7 @@
import java.security.cert.X509Certificate;
import java.util.Set;
import java.util.ArrayList;
+import java.util.List;
import java.util.logging.Logger;
import java.util.logging.Level;
@@ -154,6 +155,47 @@
}
/**
+ * Interactively prompts (on standard output) the user to provide select
+ * one option from a set of options.
+ *
+ * @param prompt The prompt to present to the user.
+ * @param defaultOption The default value returned if the user clicks enter.
+ * @param options The valid values that can be accepted as user input.
+ *
+ * @return index of options that was chosen or -1 if none where chosen
+ */
+ public int promptOptions(Message prompt,
+ Message defaultOption,
+ Message[] options) {
+ Message choiceDefault = null;
+ List<Message> choiceList = new ArrayList<Message>();
+ MessageBuilder mb = new MessageBuilder(prompt);
+ for (int i = 0; i < options.length; i++) {
+ Message choice = Message.raw(Integer.toString(i + 1));
+ choiceList.add(choice);
+ if (options[i].equals(defaultOption)) {
+ choiceDefault = choice;
+ }
+ mb.append("\n");
+ mb.append(choice);
+ mb.append(". ");
+ mb.append(options[i]);
+ }
+ int ret = -1;
+ Message resp = promptConfirm(mb.toMessage(), choiceDefault,
+ choiceList.toArray(new Message[0]));
+ if (resp != null) {
+ for (int i = 0; i < choiceList.size(); i++) {
+ if (resp.equals(choiceList.get(i))) {
+ ret = i;
+ break;
+ }
+ }
+ }
+ return ret;
+ }
+
+ /**
* Interactively prompts (on standard output) the user to provide a string
* value. Any non-empty string will be allowed (the empty string will
* indicate that the default should be used, if there is one).
@@ -166,7 +208,7 @@
*
* @return The string value read from the user.
*/
- protected String promptForString(Message prompt, String defaultValue) {
+ public String promptForString(Message prompt, String defaultValue) {
String wrappedPrompt = StaticUtils.wrapText(prompt,
Utils.getCommandLineMaxLineWidth());
@@ -391,6 +433,8 @@
}
/**
+<<<<<<< .mine
+=======
* Returns <CODE>true</CODE> if this is a quiet session and
* <CODE>false</CODE> otherwise. This method relies on the a previous
* call to createArgumentParser having been made and the parser
--
Gitblit v1.10.0