From 6ceb283261187171280d9be5c79fc2be636f2842 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 28 Jun 2007 15:20:09 +0000
Subject: [PATCH] Complete fix for issue 1613 applying the fix also to the status-panel and status command lines.

---
 opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java |   47 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java b/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
index d502668..dc92fcf 100644
--- a/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
+++ b/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
@@ -36,7 +36,12 @@
 import org.opends.quicksetup.util.Utils;
 import org.opends.quicksetup.Installation;
 import org.opends.server.core.DirectoryServer;
+import org.opends.server.util.ServerConstants;
+import org.opends.server.util.args.ArgumentParser;
+import org.opends.server.util.args.BooleanArgument;
 import org.opends.statuspanel.i18n.ResourceProvider;
+
+import static org.opends.server.messages.ToolMessages.*;
 import static org.opends.server.tools.ToolConstants.*;
 
 /**
@@ -89,7 +94,7 @@
         printVersion = true;
       }
     }
-    // We first check if we have to pribt the version
+    // We first check if we have to print the version
     if(printVersion)
     {
       try
@@ -209,21 +214,33 @@
 
   private static void printUsage(PrintStream stream)
   {
-    String arg;
-    if (Utils.isWindows())
-    {
-      arg = Installation.WINDOWS_STATUSPANEL_FILE_NAME;
-    } else
-    {
-      arg = Installation.UNIX_STATUSPANEL_FILE_NAME;
+    ArgumentParser argParser =
+      new ArgumentParser(StatusPanelLauncher.class.getName(),
+        getI18n().getMsg("status-panel-launcher-usage-description"), false);
+    BooleanArgument showUsage;
+    String scriptName;
+    if (Utils.isWindows()) {
+      scriptName = Installation.WINDOWS_STATUSPANEL_FILE_NAME;
+    } else {
+      scriptName = Installation.UNIX_STATUSPANEL_FILE_NAME;
     }
-    /*
-     * This is required because the usage message contains '{' characters that
-     * mess up the MessageFormat.format method.
-     */
-    String msg = getMsg("status-panel-launcher-usage");
-    msg = msg.replace("{0}", arg);
-    stream.println(msg);
+    System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName);
+    try
+    {
+      showUsage = new BooleanArgument("showusage", OPTION_SHORT_HELP,
+        OPTION_LONG_HELP,
+        MSGID_DESCRIPTION_USAGE);
+      argParser.addArgument(showUsage);
+      argParser.setUsageArgument(showUsage);
+
+      String msg = argParser.getUsage();
+      stream.println(msg);
+    }
+    catch (Throwable t)
+    {
+      System.out.println("ERROR: "+t);
+      t.printStackTrace();
+    }
   }
 
   /**

--
Gitblit v1.10.0