From ea9b9e87abcf36995a52d271ae34e792653fd696 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 19 Sep 2007 14:40:07 +0000
Subject: [PATCH] After some discussions it has been decided to merge the setup and uninstall commands so that we have the behavior that we had before.  So with this changes, in order to work in CLI mode the option --cli must be specified. 

---
 opends/src/quicksetup/org/opends/quicksetup/installer/SetupLauncher.java |   60 ++++++++++++++++++++++++------------------------------------
 1 files changed, 24 insertions(+), 36 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/SetupGuiLauncher.java b/opends/src/quicksetup/org/opends/quicksetup/installer/SetupLauncher.java
similarity index 74%
rename from opends/src/quicksetup/org/opends/quicksetup/installer/SetupGuiLauncher.java
rename to opends/src/quicksetup/org/opends/quicksetup/installer/SetupLauncher.java
index 4240331..5dff196 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/SetupGuiLauncher.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/SetupLauncher.java
@@ -28,9 +28,7 @@
 package org.opends.quicksetup.installer;
 
 import static org.opends.messages.QuickSetupMessages.*;
-import static org.opends.messages.ToolMessages.INFO_DESCRIPTION_SHOWUSAGE;
-import static org.opends.server.tools.ToolConstants.OPTION_LONG_HELP;
-import static org.opends.server.tools.ToolConstants.OPTION_SHORT_HELP;
+import static org.opends.messages.ToolMessages.*;
 
 import java.io.File;
 import java.util.logging.Logger;
@@ -43,31 +41,31 @@
 import org.opends.quicksetup.installer.offline.OfflineInstaller;
 import org.opends.quicksetup.util.Utils;
 import org.opends.messages.Message;
-import org.opends.messages.ToolMessages;
+import org.opends.server.tools.InstallDS;
+import org.opends.server.tools.InstallDSArgumentParser;
 import org.opends.server.util.ServerConstants;
 import org.opends.server.util.args.ArgumentException;
 import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
 
 /**
- * This class is called by the setup GUI command line to launch the setup
+ * This class is called by the setup command line to launch the setup
  * of the Directory Server. It just checks the command line arguments and the
  * environment and determines whether the graphical or the command line
  * based setup much be launched.
  */
-public class SetupGuiLauncher extends Launcher {
+public class SetupLauncher extends Launcher {
 
   /** Prefix for log files. */
-  static public final String LOG_FILE_PREFIX = "opends-setup-gui-";
+  static public final String LOG_FILE_PREFIX = "opends-setup-";
 
   /** Suffix for log files. */
   static public final String LOG_FILE_SUFFIX = ".log";
 
   static private final Logger LOG =
-          Logger.getLogger(SetupGuiLauncher.class.getName());
+          Logger.getLogger(SetupLauncher.class.getName());
 
   /**
-   * The main method which is called by the setup GUI command lines.
+   * The main method which is called by the setup command lines.
    *
    * @param args the arguments passed by the command lines.  In the case
    * we want to launch the cli setup they are basically the arguments that we
@@ -83,23 +81,23 @@
       System.err.println("Unable to initialize log");
       t.printStackTrace();
     }
-    new SetupGuiLauncher(args).launch();
+    new SetupLauncher(args).launch();
   }
 
-  private ArgumentParser argParser;
+  private InstallDSArgumentParser argParser;
 
   /**
    * Creates a launcher.
    *
    * @param args the arguments passed by the command lines.
    */
-  public SetupGuiLauncher(String[] args) {
+  public SetupLauncher(String[] args) {
     super(args);
     String scriptName;
     if (Utils.isWindows()) {
-      scriptName = Installation.WINDOWS_SETUP_GUI_FILE_NAME;
+      scriptName = Installation.WINDOWS_SETUP_FILE_NAME;
     } else {
-      scriptName = Installation.UNIX_SETUP_GUI_FILE_NAME;
+      scriptName = Installation.UNIX_SETUP_FILE_NAME;
     }
     System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName);
     initializeParser();
@@ -110,23 +108,15 @@
    */
   protected void initializeParser()
   {
-    argParser = new ArgumentParser(getClass().getName(),
-        INFO_SETUP_LAUNCHER_USAGE_DESCRIPTION.get(),
-        false);
+    argParser = new InstallDSArgumentParser(InstallDS.class.getName());
     try
     {
-      BooleanArgument showUsageArg = new BooleanArgument("showUsage",
-          OPTION_SHORT_HELP,
-          OPTION_LONG_HELP, INFO_DESCRIPTION_SHOWUSAGE.get());
-      argParser.addArgument(showUsageArg);
-      argParser.setUsageArgument(showUsageArg);
-      argParser.parseArguments(args);
+      argParser.initializeArguments();
     }
     catch (ArgumentException ae)
     {
-      System.err.println(org.opends.server.util.StaticUtils.wrapText(
-          ToolMessages.ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()),
-          Utils.getCommandLineMaxLineWidth()));
+      Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
+      System.out.println(message);
     }
   }
 
@@ -148,7 +138,12 @@
         printUsage(false);
       }
       System.exit(ReturnCode.SUCCESSFUL.getReturnCode());
-    } else {
+    }
+    else if (isCli())
+    {
+      System.exit(InstallDS.mainCLI(args));
+    }
+    else {
       willLaunchGui();
       int exitCode = launchGui(args);
       if (exitCode != 0) {
@@ -161,7 +156,7 @@
         {
           guiLaunchFailed(null);
         }
-        System.exit(exitCode);
+        System.exit(InstallDS.mainCLI(args));
       }
     }
   }
@@ -169,13 +164,6 @@
   /**
    * {@inheritDoc}
    */
-  protected boolean isCli() {
-    return false;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
   public ArgumentParser getArgumentParser() {
     return this.argParser;
   }

--
Gitblit v1.10.0