From 5e164ec03b7c543e3df639e60172fa34d97b8628 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Sat, 01 Sep 2007 17:38:28 +0000
Subject: [PATCH] Fix a number of bugs in the implementation of Replication CLI. The utility now is able to enable, disable and initialize suffixes. The latest modifications introduced by Scott in the class Installer are also included in this commit.
---
opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java | 64 ++++++++++++++++++++++++++------
1 files changed, 52 insertions(+), 12 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java b/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
index 3e83a4b..6587a2c 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
@@ -209,20 +209,48 @@
* @return The string value read from the user.
*/
public String promptForString(Message prompt, String defaultValue) {
+ return promptForString(prompt, defaultValue, true);
+ }
+
+ /**
+ * 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).
+ *
+ * @param prompt The prompt to present to the user.
+ * @param defaultValue The default value to assume if the user presses ENTER
+ * without typing anything, or <CODE>null</CODE> if
+ * there should not be a default and the user must
+ * explicitly provide a value.
+ * @param addLineBreakIfDefault adds a line break between the prompt and the
+ * default value if this is not <CODE>null</CODE>.
+ * @return The string value read from the user.
+ */
+ protected String promptForString(Message prompt, String defaultValue,
+ boolean addLineBreakIfDefault) {
String wrappedPrompt = StaticUtils.wrapText(prompt,
- Utils.getCommandLineMaxLineWidth());
+ Utils.getCommandLineMaxLineWidth());
while (true) {
if (defaultValue == null) {
out.print(wrappedPrompt);
out.print(" ");
} else {
- out.println(wrappedPrompt);
- out.print("[");
- out.print(defaultValue);
- out.print("]: ");
+ if (addLineBreakIfDefault)
+ {
+ out.println(wrappedPrompt);
+ out.print("[");
+ out.print(defaultValue);
+ out.print("]: ");
+ }
+ else
+ {
+ out.print(wrappedPrompt);
+ out.print(" [");
+ out.print(defaultValue);
+ out.print("]: ");
+ }
}
-
out.flush();
String response = readLine();
@@ -266,10 +294,6 @@
{
pwd = new String(pwChars);
}
- // Sometimes the backspace trick creates problems in the terminal and
- // out.println() does not write a new line. printing a space fixes the
- // problem
- out.print(" ");
out.flush();
}
catch (Throwable t)
@@ -288,10 +312,25 @@
*/
protected int promptForPort(Message msg, int defaultValue)
{
+ return promptForPort(msg, defaultValue, true);
+ }
+
+ /**
+ * Prompts the user to provide a port.
+ * @param msg the message to be displayed.
+ * @param defaultValue the default value to be proposed.
+ * @param addLineBreakIfDefault adds a line break between the prompt and the
+ * default value if this is not <CODE>null</CODE>.
+ * @return the user to provide a port.
+ */
+ protected int promptForPort(Message msg, int defaultValue,
+ boolean addLineBreakIfDefault)
+ {
int port = -1;
while (port == -1)
{
- String s = promptForString(msg, String.valueOf(defaultValue));
+ String s = promptForString(msg, String.valueOf(defaultValue),
+ addLineBreakIfDefault);
if ((s != null) && (s.trim().length() > 0))
{
try
@@ -610,7 +649,8 @@
*/
protected String askForAdministratorUID(String defaultValue)
{
- return promptForString(INFO_ADMINISTRATOR_UID_PROMPT.get(), defaultValue);
+ return promptForString(INFO_ADMINISTRATOR_UID_PROMPT.get(), defaultValue,
+ false);
}
/**
--
Gitblit v1.10.0