mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
04.55.2007 b1aa376919f5d5adb5747be5f46703032f639c98
In the case where the user asked for the usage of the setup, uninstall or upgrade CLI, we were returning an error code systematically (the error code corresponding to an error in the data provided by the user).  
With this modifications when the user asks for the usage explicitly we return an error code 0. In addition to that, when the usage is asked explicitly in the command line for the usage it is written to the standard output. When we display the usage because of an error on the data provided by the user the usage is displayed in the error output.
4 files modified
49 ■■■■■ changed files
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Launcher.java 34 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java 7 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java 4 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeLauncher.java 4 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
@@ -150,14 +150,20 @@
  }
  /**
   * Prints a usage message to the terminal and exits
   * with exit code QuickSetupCli.USER_DATA_ERROR.
   * @param i18nMsg localized user message that will
   * be printed to std error
   * Prints a usage message to the terminal.
   * @param i18nMsg localized user message that will be printed to the terminal.
   * @param toStdErr whether the message must be printed to the standard error
   * or the standard output.
   */
  protected void printUsage(String i18nMsg) {
  protected void printUsage(String i18nMsg, boolean toStdErr) {
    if (toStdErr)
    {
    System.err.println(i18nMsg);
    System.exit(QuickSetupCli.USER_DATA_ERROR);
    }
    else
    {
      System.out.println(i18nMsg);
    }
  }
  /**
@@ -255,14 +261,14 @@
    QuickSetupCli cli = new QuickSetupCli(cliApp, args);
    int returnValue = cli.run();
    if (returnValue == QuickSetupCli.USER_DATA_ERROR) {
      printUsage();
      printUsage(true);
      System.exit(QuickSetupCli.USER_DATA_ERROR);
    }
    return returnValue;
  }
  /**
   * Prints the version statement to terminal and exits
   * with an error code.
   * Prints the version statement to standard output terminal.
   */
  private void printVersion()
  {
@@ -272,8 +278,10 @@
  /**
   * Prints a usage statement to terminal and exits with an error
   * code.
   * @param toStdErr whether the message must be printed to the standard error
   * or the standard output.
   */
  protected abstract void printUsage();
  protected abstract void printUsage(boolean toStdErr);
  /**
   * Creates a CLI application that will be run if the
@@ -300,15 +308,17 @@
  protected abstract void guiLaunchFailed(String logFileName);
  /**
   * The main method which is called by the uninstall command lines.
   * The main method which is called by the command lines.
   */
  public void launch() {
    if (shouldPrintVersion())
    {
      printVersion();
      System.exit(QuickSetupCli.SUCCESSFUL);
    }
    else if (shouldPrintUsage()) {
      printUsage();
      printUsage(false);
      System.exit(QuickSetupCli.SUCCESSFUL);
    } else if (isCli()) {
      CliApplication cliApp = createCliApplication();
      int exitCode = launchCli(args, cliApp);
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java
@@ -138,6 +138,9 @@
    System.out.println(getMsg("setup-launcher-launching-gui"));
    System.setProperty("org.opends.quicksetup.Application.class",
            "org.opends.quicksetup.installer.offline.OfflineInstaller");
    // TO DELETE
    System.setProperty("org.opends.quicksetup.Application.class",
    "org.opends.quicksetup.installandupgrader.InstallAndUpgrader");
  }
  /**
@@ -150,7 +153,7 @@
  /**
   * {@inheritDoc}
   */
  public void printUsage() {
  protected void printUsage(boolean toStdErr) {
    String scriptName;
    if (Utils.isWindows()) {
      scriptName = Installation.WINDOWS_SETUP_FILE_NAME;
@@ -264,7 +267,7 @@
      argParser.addArgument(showUsage);
      argParser.setUsageArgument(showUsage);
      String msg = argParser.getUsage();
      printUsage(msg);
      printUsage(msg, toStdErr);
    }
    catch (Throwable t)
    {
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
@@ -127,7 +127,7 @@
  /**
   * {@inheritDoc}
   */
  protected void printUsage() {
  protected void printUsage(boolean toStdErr) {
    ArgumentParser argParser = new ArgumentParser(getClass().getName(),
        getI18n().getMsg("uninstall-launcher-usage-description"), false);
    BooleanArgument cli;
@@ -155,7 +155,7 @@
      argParser.setUsageArgument(showUsage);
      String msg = argParser.getUsage();
      printUsage(msg);
      printUsage(msg, toStdErr);
    }
    catch (Throwable t)
    {
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeLauncher.java
@@ -94,7 +94,7 @@
  /**
   * {@inheritDoc}
   */
  protected void printUsage() {
  protected void printUsage(boolean toStdErr) {
    ArgumentParser argParser = new ArgumentParser(getClass().getName(),
        getI18n().getMsg("upgrade-launcher-usage-description"), false);
    BooleanArgument showUsage;
@@ -128,7 +128,7 @@
      argParser.setUsageArgument(showUsage);
      String msg = argParser.getUsage();
      printUsage(msg);
      printUsage(msg, toStdErr);
    }
    catch (Throwable t)
    {