accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1208759 - /incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
Date Wed, 30 Nov 2011 20:39:20 GMT
Author: billie
Date: Wed Nov 30 20:39:19 2011
New Revision: 1208759

URL: http://svn.apache.org/viewvc?rev=1208759&view=rev
Log:
ACCUMULO-170 print a friendly "unknown command" instead

Modified:
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java?rev=1208759&r1=1208758&r2=1208759&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
Wed Nov 30 20:39:19 2011
@@ -22,9 +22,9 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.accumulo.core.util.shell.Shell;
+import org.apache.accumulo.core.util.shell.Shell.Command;
 import org.apache.accumulo.core.util.shell.ShellCommandException;
 import org.apache.accumulo.core.util.shell.Token;
-import org.apache.accumulo.core.util.shell.Shell.Command;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
@@ -49,12 +49,11 @@ public class HelpCommand extends Command
     
     // print help for every command on command line
     for (String cmd : cl.getArgs()) {
-      try {
-        shellState.commandFactory.get(cmd).printHelp();
-      } catch (Exception e) {
-        Shell.printException(e);
-        return 1;
-      }
+      Command c = shellState.commandFactory.get(cmd);
+      if (c == null)
+        shellState.getReader().printString(String.format("Unknown command \"%s\".  Enter
\"help\" for a list possible commands.\n", cmd));
+      else
+        c.printHelp();
     }
     return 0;
   }
@@ -84,4 +83,4 @@ public class HelpCommand extends Command
   public int numArgs() {
     return Shell.NO_FIXED_ARG_LENGTH_CHECK;
   }
-}
\ No newline at end of file
+}



Mime
View raw message