accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1333178 - in /accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell: Shell.java commands/HelpCommand.java commands/HiddenCommand.java
Date Wed, 02 May 2012 20:02:02 GMT
Author: billie
Date: Wed May  2 20:02:01 2012
New Revision: 1333178

URL: http://svn.apache.org/viewvc?rev=1333178&view=rev
Log:
ACCUMULO-376 organized shell commands

Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java?rev=1333178&r1=1333177&r2=1333178&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java Wed May
 2 20:02:01 2012
@@ -167,6 +167,7 @@ public class Shell extends ShellOptions 
   
   private Token rootToken;
   public final Map<String,Command> commandFactory = new TreeMap<String,Command>();
+  public final Map<String,Command[]> commandGrouping = new TreeMap<String,Command[]>();
   protected boolean configError = false;
   
   // exit if true
@@ -279,18 +280,42 @@ public class Shell extends ShellOptions 
     }
     
     rootToken = new Token();
-    Command external[] = {new AboutCommand(), new AddSplitsCommand(), new AuthenticateCommand(),
new ByeCommand(), new ClasspathCommand(), new ClearCommand(),
-        new CloneTableCommand(), new ClsCommand(), new CompactCommand(), new ConfigCommand(),
new CreateTableCommand(), new CreateUserCommand(),
-        new DebugCommand(), new DeleteCommand(), new DeleteIterCommand(), new DeleteManyCommand(),
new DeleteRowsCommand(), new DeleteScanIterCommand(),
-        new DeleteTableCommand(), new DeleteUserCommand(), new DropTableCommand(), new DropUserCommand(),
new DUCommand(), new EGrepCommand(),
-        new ExecfileCommand(), new ExitCommand(), new FlushCommand(), new FormatterCommand(),
new GetAuthsCommand(), new GetGroupsCommand(),
-        new GetSplitsCommand(), new GrantCommand(), new GrepCommand(), new HelpCommand(),
new HiddenCommand(), new HistoryCommand(),
-        new ImportDirectoryCommand(), new InfoCommand(), new InsertCommand(), new ListIterCommand(),
new ListScansCommand(), new MaxRowCommand(),
-        new MergeCommand(), new NoTableCommand(), new OfflineCommand(), new OnlineCommand(),
new PasswdCommand(), new QuestionCommand(), new QuitCommand(),
-        new RenameTableCommand(), new RevokeCommand(), new ScanCommand(), new SetAuthsCommand(),
new SetGroupsCommand(), new SetIterCommand(),
-        new SetScanIterCommand(), new SleepCommand(), new SystemPermissionsCommand(), new
TableCommand(), new TablePermissionsCommand(), new TablesCommand(),
-        new TraceCommand(), new UserCommand(), new UserPermissionsCommand(), new UsersCommand(),
new WhoAmICommand(),};
-    for (Command cmd : external) {
+    
+    Command[] dataCommands = {new DeleteCommand(), new DeleteManyCommand(), new DeleteRowsCommand(),
new EGrepCommand(), new FormatterCommand(),
+        new GrepCommand(), new ImportDirectoryCommand(), new InsertCommand(), new MaxRowCommand(),
new ScanCommand()};
+    Command[] debuggingCommands = {new ClasspathCommand(), new DebugCommand(), new ListScansCommand(),
new TraceCommand()};
+    Command[] execCommands = {new ExecfileCommand(), new HistoryCommand()};
+    Command[] exitCommands = {new ByeCommand(), new ExitCommand(), new QuitCommand()};
+    Command[] helpCommands = {new AboutCommand(), new HelpCommand(), new InfoCommand(), new
QuestionCommand()};
+    Command[] iteratorCommands = {new DeleteIterCommand(), new DeleteScanIterCommand(), new
ListIterCommand(), new SetIterCommand(), new SetScanIterCommand()};
+    Command[] otherCommands = {new HiddenCommand()};
+    Command[] permissionsCommands = {new GrantCommand(), new RevokeCommand(), new SystemPermissionsCommand(),
new TablePermissionsCommand(),
+        new UserPermissionsCommand()};
+    Command[] stateCommands = {new AuthenticateCommand(), new ClsCommand(), new ClearCommand(),
new NoTableCommand(), new SleepCommand(), new TableCommand(),
+        new UserCommand(), new WhoAmICommand()};
+    Command[] tableCommands = {new CloneTableCommand(), new ConfigCommand(), new CreateTableCommand(),
new DeleteTableCommand(), new DropTableCommand(),
+        new DUCommand(), new OfflineCommand(), new OnlineCommand(), new RenameTableCommand(),
new TablesCommand()};
+    Command[] tableControlCommands = {new AddSplitsCommand(), new CompactCommand(), new FlushCommand(),
new GetGroupsCommand(), new GetSplitsCommand(),
+        new MergeCommand(), new SetGroupsCommand()};
+    Command[] userCommands = {new CreateUserCommand(), new DeleteUserCommand(), new DropUserCommand(),
new GetAuthsCommand(), new PasswdCommand(),
+        new SetAuthsCommand(), new UsersCommand()};
+    commandGrouping.put("-- Writing, Reading, and Removing Data --", dataCommands);
+    commandGrouping.put("-- Debugging Commands -------------------", debuggingCommands);
+    commandGrouping.put("-- Shell Execution Commands -------------", execCommands);
+    commandGrouping.put("-- Exiting Commands ---------------------", exitCommands);
+    commandGrouping.put("-- Help Commands ------------------------", helpCommands);
+    commandGrouping.put("-- Iterator Configuration ---------------", iteratorCommands);
+    commandGrouping.put("-- Permissions Administration Commands --", permissionsCommands);
+    commandGrouping.put("-- Shell State Commands -----------------", stateCommands);
+    commandGrouping.put("-- Table Administration Commands --------", tableCommands);
+    commandGrouping.put("-- Table Control Commands ---------------", tableControlCommands);
+    commandGrouping.put("-- User Administration Commands ---------", userCommands);
+    
+    for (Command[] cmds : commandGrouping.values()) {
+      for (Command cmd : cmds)
+        commandFactory.put(cmd.getName(), cmd);
+    }
+    for (Command cmd : otherCommands) {
       commandFactory.put(cmd.getName(), cmd);
     }
   }
@@ -574,11 +599,13 @@ public class Shell extends ShellOptions 
     options.put(Command.CompletionSet.TABLENAMES, modifiedTablenames);
     options.put(Command.CompletionSet.COMMANDS, commands);
     
-    for (Command c : commandFactory.values()) {
-      c.getOptionsWithHelp(); // prep the options for the command
-      // so that the completion can
-      // include them
-      c.registerCompletion(rootToken, options);
+    for (Command[] cmdGroup : commandGrouping.values()) {
+      for (Command c : cmdGroup) {
+        c.getOptionsWithHelp(); // prep the options for the command
+        // so that the completion can
+        // include them
+        c.registerCompletion(rootToken, options);
+      }
     }
     return new ShellCompletor(rootToken, options);
   }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java?rev=1333178&r1=1333177&r2=1333178&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
Wed May  2 20:02:01 2012
@@ -19,6 +19,7 @@ package org.apache.accumulo.core.util.sh
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import org.apache.accumulo.core.util.shell.Shell;
@@ -46,8 +47,9 @@ public class HelpCommand extends Command
       if (numColumns < 40)
         throw new IllegalArgumentException("numColumns must be at least 40 (was " + numColumns
+ ")");
       ArrayList<String> output = new ArrayList<String>();
-      for (Command c : shellState.commandFactory.values()) {
-        if (!(c instanceof HiddenCommand)) {
+      for (Entry<String,Command[]> cmdGroup : shellState.commandGrouping.entrySet())
{
+        output.add(cmdGroup.getKey());
+        for (Command c : cmdGroup.getValue()) {
           String n = c.getName();
           String s = c.description();
           if (s == null)
@@ -76,6 +78,7 @@ public class HelpCommand extends Command
           }
           output.add(String.format("%-" + i + "s  %s  %s", n, dash, s.substring(beginIndex,
endIndex)));
         }
+        output.add("");
       }
       shellState.printLines(output.iterator(), !cl.hasOption(disablePaginationOpt.getOpt()));
     }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java?rev=1333178&r1=1333177&r2=1333178&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java
Wed May  2 20:02:01 2012
@@ -20,10 +20,11 @@ import java.security.SecureRandom;
 import java.util.Random;
 
 import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.ShellCommandException;
 import org.apache.accumulo.core.util.shell.Shell.Command;
+import org.apache.accumulo.core.util.shell.ShellCommandException;
 import org.apache.accumulo.core.util.shell.ShellCommandException.ErrorCode;
 import org.apache.commons.cli.CommandLine;
+import org.apache.commons.codec.binary.Base64;
 
 public class HiddenCommand extends Command {
   private static Random rand = new SecureRandom();
@@ -38,7 +39,10 @@ public class HiddenCommand extends Comma
     if (rand.nextInt(10) == 0) {
       shellState.getReader().beep();
       shellState.getReader().printNewline();
-      shellState.getReader().printString("Sortacus lives!\n");
+      shellState.getReader().printString(
+          new String(Base64.decodeBase64(("ICAgICAgIC4tLS4KICAgICAgLyAvXCBcCiAgICAgKCAvLS1cICkKICAgICAuPl8gIF88LgogICAgLyB8ICd8ICcgXAog"
+              + "ICAvICB8Xy58Xy4gIFwKICAvIC98ICAgICAgfFwgXAogfCB8IHwgfFwvfCB8IHwgfAogfF98IHwgfCAgfCB8IHxffAogICAgIC8gIF9fICBcCiAgICAvICAv"
+              + "ICBcICBcCiAgIC8gIC8gICAgXCAgXF8KIHwvICAvICAgICAgXCB8IHwKIHxfXy8gICAgICAgIFx8X3wK").getBytes())));
       shellState.getReader().printNewline();
     } else
       throw new ShellCommandException(ErrorCode.UNRECOGNIZED_COMMAND, getName());
@@ -53,6 +57,6 @@ public class HiddenCommand extends Comma
   
   @Override
   public String getName() {
-    return "\0\0\0\0";
+    return new String("accvmvlo");
   }
 }



Mime
View raw message