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/Launcher.java | 65 +++++++++++++++++++++++++++-----
1 files changed, 54 insertions(+), 11 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Launcher.java b/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
index d46f1c0..f3ad57d 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
@@ -100,6 +100,46 @@
}
/**
+ * Indicates whether or not the launcher should print a usage
+ * statement based on the content of the arguments passed into
+ * the constructor.
+ * @return boolean where true indicates usage should be printed
+ */
+ protected boolean isQuiet() {
+ boolean printUsage = false;
+ if ((args != null) && (args.length > 0)) {
+ for (String arg : args) {
+ if (arg.equals("-?") ||
+ arg.equalsIgnoreCase("-Q") ||
+ arg.equalsIgnoreCase("--quiet")) {
+ printUsage = true;
+ }
+ }
+ }
+ return printUsage;
+ }
+
+ /**
+ * Indicates whether or not the launcher should print a usage
+ * statement based on the content of the arguments passed into
+ * the constructor.
+ * @return boolean where true indicates usage should be printed
+ */
+ protected boolean isNoPrompt() {
+ boolean printUsage = false;
+ if ((args != null) && (args.length > 0)) {
+ for (String arg : args) {
+ if (arg.equals("-?") ||
+ arg.equalsIgnoreCase("-n") ||
+ arg.equalsIgnoreCase("--no-prompt")) {
+ printUsage = true;
+ }
+ }
+ }
+ return printUsage;
+ }
+
+ /**
* Indicates whether or not the launcher should print a version
* statement based on the content of the arguments passed into
* the constructor.
@@ -249,12 +289,11 @@
{
System.setProperty(Constants.CLI_JAVA_PROPERTY, "true");
QuickSetupCli cli = new QuickSetupCli(cliApp, this);
- ApplicationReturnCode.ReturnCode returnValue = cli.run();
- if (returnValue.equals(ApplicationReturnCode.ReturnCode.USER_DATA_ERROR))
+ ReturnCode returnValue = cli.run();
+ if (returnValue.equals(ReturnCode.USER_DATA_ERROR))
{
printUsage(true);
- System.exit(ApplicationReturnCode.ReturnCode.USER_DATA_ERROR
- .getReturnCode());
+ System.exit(ReturnCode.USER_DATA_ERROR.getReturnCode());
}
return returnValue.getReturnCode();
}
@@ -317,15 +356,19 @@
* The main method which is called by the command lines.
*/
public void launch() {
- if (shouldPrintVersion())
- {
- printVersion();
- System.exit(ApplicationReturnCode.ReturnCode.PRINT_VERSION
- .getReturnCode());
+ if (shouldPrintVersion()) {
+ ArgumentParser parser = getArgumentParser();
+ if (parser == null || !parser.usageOrVersionDisplayed()) {
+ printVersion();
+ }
+ System.exit(ReturnCode.PRINT_VERSION.getReturnCode());
}
else if (shouldPrintUsage()) {
- printUsage(false);
- System.exit(ApplicationReturnCode.ReturnCode.SUCCESSFUL.getReturnCode());
+ ArgumentParser parser = getArgumentParser();
+ if (parser == null || !parser.usageOrVersionDisplayed()) {
+ printUsage(false);
+ }
+ System.exit(ReturnCode.SUCCESSFUL.getReturnCode());
} else if (isCli()) {
CliApplication cliApp = createCliApplication();
int exitCode = launchCli(cliApp);
--
Gitblit v1.10.0