incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/2] git commit: Adding shell commands to list and describe platform commands.
Date Tue, 23 Sep 2014 13:20:52 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master bd00416db -> 86f30c9aa


Adding shell commands to list and describe platform commands.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/7db1e37e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/7db1e37e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/7db1e37e

Branch: refs/heads/master
Commit: 7db1e37eedaaf2a1589efff8664b3238d0864142
Parents: bd00416
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Sep 23 09:06:52 2014 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Sep 23 09:06:52 2014 -0400

----------------------------------------------------------------------
 .../org/apache/blur/command/DocumentCount.java  |   4 +-
 .../blur/command/DocumentCountCombiner.java     |   4 +-
 .../blur/command/DocumentCountNoCombine.java    |   4 +-
 .../apache/blur/command/BaseCommandManager.java |   9 +-
 .../blur/command/annotation/Argument.java       |   2 +
 .../org/apache/blur/command/WaitForSeconds.java |   6 +-
 .../java/org/apache/blur/shell/Command.java     |   7 ++
 .../org/apache/blur/shell/CommandCompletor.java |  46 ++++-----
 .../blur/shell/CommandFirstArgCommand.java      |  22 ++++
 .../shell/DescribePlatformCommandCommand.java   | 100 +++++++++++++++++++
 .../org/apache/blur/shell/FirstArgCommand.java  |  22 ++++
 .../blur/shell/ListPlatformCommandsCommand.java |  79 +++++++++++++++
 .../main/java/org/apache/blur/shell/Main.java   |   8 +-
 .../apache/blur/shell/TableFirstArgCommand.java |   2 +-
 14 files changed, 267 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-command/src/main/java/org/apache/blur/command/DocumentCount.java
----------------------------------------------------------------------
diff --git a/blur-command/src/main/java/org/apache/blur/command/DocumentCount.java b/blur-command/src/main/java/org/apache/blur/command/DocumentCount.java
index ecf5b36..0eff004 100644
--- a/blur-command/src/main/java/org/apache/blur/command/DocumentCount.java
+++ b/blur-command/src/main/java/org/apache/blur/command/DocumentCount.java
@@ -28,8 +28,8 @@ import org.apache.blur.command.annotation.OptionalArguments;
 
 @SuppressWarnings("serial")
 @Description("Gets the number of visible documents in the index.")
-@RequiredArguments({ @Argument(name = "table", value = "The name of the table to execute
the document count command.") })
-@OptionalArguments({ @Argument(name = "shard", value = "The shard id to execute the document
count command.") })
+@RequiredArguments({ @Argument(name = "table", value = "The name of the table to execute
the document count command.", type = String.class) })
+@OptionalArguments({ @Argument(name = "shard", value = "The shard id to execute the document
count command.", type = String.class) })
 public class DocumentCount extends Command implements IndexReadCommand<Integer> {
 
   private static final String DOC_COUNT = "docCount";

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-command/src/main/java/org/apache/blur/command/DocumentCountCombiner.java
----------------------------------------------------------------------
diff --git a/blur-command/src/main/java/org/apache/blur/command/DocumentCountCombiner.java
b/blur-command/src/main/java/org/apache/blur/command/DocumentCountCombiner.java
index e0db579..45d6cd7 100644
--- a/blur-command/src/main/java/org/apache/blur/command/DocumentCountCombiner.java
+++ b/blur-command/src/main/java/org/apache/blur/command/DocumentCountCombiner.java
@@ -34,8 +34,8 @@ import org.apache.blur.command.annotation.OptionalArguments;
 
 @SuppressWarnings("serial")
 @Description("Gets the number of visible documents in the index.")
-@RequiredArguments({ @Argument(name = "table", value = "The name of the table to execute
the document count command.") })
-@OptionalArguments({ @Argument(name = "shard", value = "The shard id to execute the document
count command.") })
+@RequiredArguments({ @Argument(name = "table", value = "The name of the table to execute
the document count command.", type = String.class) })
+@OptionalArguments({ @Argument(name = "shard", value = "The shard id to execute the document
count command.", type = String.class) })
 public class DocumentCountCombiner extends Command implements ClusterCommand<Long>,
     IndexReadCombiningCommand<Integer, Long> {
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-command/src/main/java/org/apache/blur/command/DocumentCountNoCombine.java
----------------------------------------------------------------------
diff --git a/blur-command/src/main/java/org/apache/blur/command/DocumentCountNoCombine.java
b/blur-command/src/main/java/org/apache/blur/command/DocumentCountNoCombine.java
index 0ddd045..e7a74c6 100644
--- a/blur-command/src/main/java/org/apache/blur/command/DocumentCountNoCombine.java
+++ b/blur-command/src/main/java/org/apache/blur/command/DocumentCountNoCombine.java
@@ -33,8 +33,8 @@ import org.apache.blur.command.annotation.OptionalArguments;
 
 @SuppressWarnings("serial")
 @Description("Gets the number of visible documents in the index.")
-@RequiredArguments({ @Argument(name = "table", value = "The name of the table to execute
the document count command.") })
-@OptionalArguments({ @Argument(name = "shard", value = "The shard id to execute the document
count command.") })
+@RequiredArguments({ @Argument(name = "table", value = "The name of the table to execute
the document count command.", type = String.class) })
+@OptionalArguments({ @Argument(name = "shard", value = "The shard id to execute the document
count command.", type = String.class) })
 public class DocumentCountNoCombine extends Command implements IndexReadCommand<Integer>,
ClusterCommand<Long> {
 
   private static final String DOC_COUNT_NO_COMBINE = "docCountNoCombine";

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-core/src/main/java/org/apache/blur/command/BaseCommandManager.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/command/BaseCommandManager.java b/blur-core/src/main/java/org/apache/blur/command/BaseCommandManager.java
index 514932d..7169077 100644
--- a/blur-core/src/main/java/org/apache/blur/command/BaseCommandManager.java
+++ b/blur-core/src/main/java/org/apache/blur/command/BaseCommandManager.java
@@ -129,7 +129,8 @@ public class BaseCommandManager implements Closeable {
       return arguments;
     }
     for (Argument argument : args) {
-      arguments.put(argument.name(), argument.value());
+      Class<?> type = argument.type();
+      arguments.put(argument.name(), ("(" + type.getSimpleName() + ") " + argument.value()).trim());
     }
     return arguments;
   }
@@ -433,12 +434,12 @@ public class BaseCommandManager implements Closeable {
         IndexReadCommand<?> indexReadCommand = (IndexReadCommand<?>) command;
         Method method = indexReadCommand.getClass().getMethod("execute", new Class[] { IndexContext.class
});
         Class<?> returnType = method.getReturnType();
-        shardServerReturn = "shard->" + returnType.getSimpleName();
+        shardServerReturn = "shard->(" + returnType.getSimpleName() + ")";
       } else if (command instanceof IndexReadCombiningCommand) {
         IndexReadCombiningCommand<?, ?> indexReadCombiningCommand = (IndexReadCombiningCommand<?,
?>) command;
         Method method = indexReadCombiningCommand.getClass().getMethod("combine", new Class[]
{ Map.class });
         Class<?> returnType = method.getReturnType();
-        shardServerReturn = "server->" + returnType.getSimpleName();
+        shardServerReturn = "server->(" + returnType.getSimpleName() + ")";
       } else {
         shardServerReturn = null;
       }
@@ -446,7 +447,7 @@ public class BaseCommandManager implements Closeable {
         ClusterCommand<?> clusterCommand = (ClusterCommand<?>) command;
         Method method = clusterCommand.getClass().getMethod("clusterExecute", new Class[]
{ Map.class });
         Class<?> returnType = method.getReturnType();
-        String clusterReturn = "cluster->" + returnType.getSimpleName();
+        String clusterReturn = "cluster->(" + returnType.getSimpleName() + ")";
         if (shardServerReturn == null) {
           return clusterReturn;
         } else {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-core/src/main/java/org/apache/blur/command/annotation/Argument.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/command/annotation/Argument.java b/blur-core/src/main/java/org/apache/blur/command/annotation/Argument.java
index 0f68e1c..e083326 100644
--- a/blur-core/src/main/java/org/apache/blur/command/annotation/Argument.java
+++ b/blur-core/src/main/java/org/apache/blur/command/annotation/Argument.java
@@ -25,4 +25,6 @@ public @interface Argument {
   String name();
 
   String value();
+  
+  Class<?> type();
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-core/src/test/java/org/apache/blur/command/WaitForSeconds.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/command/WaitForSeconds.java b/blur-core/src/test/java/org/apache/blur/command/WaitForSeconds.java
index 50180de..32ce8a0 100644
--- a/blur-core/src/test/java/org/apache/blur/command/WaitForSeconds.java
+++ b/blur-core/src/test/java/org/apache/blur/command/WaitForSeconds.java
@@ -27,11 +27,11 @@ import org.apache.blur.command.annotation.RequiredArguments;
 import org.apache.blur.command.annotation.OptionalArguments;
 
 @SuppressWarnings("serial")
-@RequiredArguments({ @Argument(name = "table", value = "The name of the table to execute
the wait for N number of seconds command.") })
+@RequiredArguments({ @Argument(name = "table", value = "The name of the table to execute
the wait for N number of seconds command.", type = String.class) })
 @OptionalArguments({
 
-@Argument(name = "shard", value = "The shard id to execute the wait for N number of seconds
command."),
-    @Argument(name = "seconds", value = "The number of seconds to sleep, the default is 30
seconds.")
+    @Argument(name = "shard", value = "The shard id to execute the wait for N number of seconds
command.", type = String.class),
+    @Argument(name = "seconds", value = "The number of seconds to sleep, the default is 30
seconds.", type = Integer.class)
 
 })
 public class WaitForSeconds extends Command implements IndexReadCommand<Boolean> {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-shell/src/main/java/org/apache/blur/shell/Command.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/Command.java b/blur-shell/src/main/java/org/apache/blur/shell/Command.java
index 193c432..04fcb33 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/Command.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/Command.java
@@ -61,4 +61,11 @@ public abstract class Command {
     this.consoleReader = consoleReader;
   }
 
+  protected String addWhiteSpace(String s, int width) {
+    while (s.length() < width) {
+      s = s + " ";
+    }
+    return s;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-shell/src/main/java/org/apache/blur/shell/CommandCompletor.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/CommandCompletor.java b/blur-shell/src/main/java/org/apache/blur/shell/CommandCompletor.java
index c1c13b1..b2a6de9 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/CommandCompletor.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/CommandCompletor.java
@@ -32,6 +32,7 @@ import jline.console.completer.Completer;
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.CommandDescriptor;
 
 public class CommandCompletor implements Completer {
 
@@ -80,19 +81,19 @@ public class CommandCompletor implements Completer {
     if (cmd == null) {
       return null;
     }
-    if (cmd instanceof TableFirstArgCommand) {
-      String tablePartial = "";
+    if (cmd instanceof FirstArgCommand) {
+      String partial = "";
       if (args.length == 2) {
-        tablePartial = args[1];
+        partial = args[1];
       }
       if (Main.cluster != null) {
         try {
-          List<String> list = new ArrayList<String>(_client.tableListByCluster(Main.cluster));
+          List<String> list = getOptions(cmd);
           Collections.sort(list);
           List<String> results = new ArrayList<String>();
-          for (String table : list) {
-            if (table.startsWith(tablePartial)) {
-              results.add(args[0] + " " + table);
+          for (String option : list) {
+            if (option.startsWith(partial)) {
+              results.add(args[0] + " " + option);
             }
           }
           return results;
@@ -112,30 +113,19 @@ public class CommandCompletor implements Completer {
     return null;
   }
 
-  public int complete(Iface client, String potentialTable, List<CharSequence> candidates,
String commandName)
-      throws BlurException, TException {
-    SortedSet<String> tableList = new TreeSet<String>(client.tableList());
-    // buffer could be null
-    checkNotNull(candidates);
-
-    if (potentialTable == null) {
-      for (String table : tableList) {
-        candidates.add(commandName + " " + table);
+  private List<String> getOptions(Command cmd) throws BlurException, TException {
+    if (cmd instanceof TableFirstArgCommand) {
+      return new ArrayList<String>(_client.tableListByCluster(Main.cluster));
+    } else if (cmd instanceof CommandFirstArgCommand) {
+      List<CommandDescriptor> listInstalledCommands = _client.listInstalledCommands();
+      List<String> list = new ArrayList<String>();
+      for (CommandDescriptor commandDescriptor : listInstalledCommands) {
+        list.add(commandDescriptor.getCommandName());
       }
+      return list;
     } else {
-      for (String match : tableList.tailSet(potentialTable)) {
-        if (!match.startsWith(potentialTable)) {
-          break;
-        }
-        candidates.add(commandName + " " + match);
-      }
+      return new ArrayList<String>();
     }
-
-    if (candidates.size() == 1) {
-      candidates.set(0, candidates.get(0) + " ");
-    }
-
-    return candidates.isEmpty() ? -1 : 0;
   }
 
   private SortedSet<String> sort(Set<String> set) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-shell/src/main/java/org/apache/blur/shell/CommandFirstArgCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/CommandFirstArgCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/CommandFirstArgCommand.java
new file mode 100644
index 0000000..2516a8b
--- /dev/null
+++ b/blur-shell/src/main/java/org/apache/blur/shell/CommandFirstArgCommand.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.shell;
+
+public interface CommandFirstArgCommand extends FirstArgCommand {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-shell/src/main/java/org/apache/blur/shell/DescribePlatformCommandCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/DescribePlatformCommandCommand.java
b/blur-shell/src/main/java/org/apache/blur/shell/DescribePlatformCommandCommand.java
new file mode 100644
index 0000000..5ab7c89
--- /dev/null
+++ b/blur-shell/src/main/java/org/apache/blur/shell/DescribePlatformCommandCommand.java
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.blur.shell;
+
+import java.io.PrintWriter;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.TException;
+import org.apache.blur.thrift.generated.Blur;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.CommandDescriptor;
+
+public class DescribePlatformCommandCommand extends Command implements CommandFirstArgCommand
{
+  @Override
+  public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException,
TException,
+      BlurException {
+    if (args.length != 2) {
+      throw new CommandException("Invalid args: " + help());
+    }
+    String commandName = args[1];
+
+    List<CommandDescriptor> listInstalledCommands = client.listInstalledCommands();
+    for (CommandDescriptor commandDescriptor : listInstalledCommands) {
+      if (commandDescriptor.getCommandName().equals(commandName)) {
+        print(out, commandDescriptor);
+        return;
+      }
+    }
+  }
+
+  private void print(PrintWriter out, CommandDescriptor commandDescriptor) {
+    String commandName = commandDescriptor.getCommandName();
+    int width = 20;
+    out.println(addWhiteSpace("Name:", width) + commandName);
+    String description = commandDescriptor.getDescription();
+    if (description != null) {
+      out.println(addWhiteSpace("Description:", width) + description);
+    }
+
+    String returnType = commandDescriptor.getReturnType();
+    out.println(addWhiteSpace("Return Type:", width) + returnType);
+    String version = commandDescriptor.getVersion();
+    if (version.equals("0")) {
+      out.println(addWhiteSpace("Version:", width) + "Installed from classpath.");
+    } else {
+      out.println(addWhiteSpace("Version:", width) + version);
+    }
+
+    Map<String, String> requiredArguments = commandDescriptor.getRequiredArguments();
+    if (requiredArguments != null && !requiredArguments.isEmpty()) {
+      out.println();
+      out.println("Required Arguments:");
+      for (Entry<String, String> e : requiredArguments.entrySet()) {
+        out.println(addWhiteSpace("-" + e.getKey(), width) + e.getValue());
+      }
+    }
+    Map<String, String> optionalArguments = commandDescriptor.getOptionalArguments();
+    if (optionalArguments != null && !optionalArguments.isEmpty()) {
+      out.println();
+      out.println("Optional Arguments");
+      for (Entry<String, String> e : optionalArguments.entrySet()) {
+        out.println(addWhiteSpace("-" + e.getKey(), width) + e.getValue());
+      }
+    }
+    out.println();
+  }
+
+  @Override
+  public String description() {
+    return "Describes the specifed command.";
+  }
+
+  @Override
+  public String usage() {
+    return "<command name>";
+  }
+
+  @Override
+  public String name() {
+    return "command-desc";
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-shell/src/main/java/org/apache/blur/shell/FirstArgCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/FirstArgCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/FirstArgCommand.java
new file mode 100644
index 0000000..c3015d8
--- /dev/null
+++ b/blur-shell/src/main/java/org/apache/blur/shell/FirstArgCommand.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.shell;
+
+public interface FirstArgCommand {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-shell/src/main/java/org/apache/blur/shell/ListPlatformCommandsCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/ListPlatformCommandsCommand.java
b/blur-shell/src/main/java/org/apache/blur/shell/ListPlatformCommandsCommand.java
new file mode 100644
index 0000000..2cf330f
--- /dev/null
+++ b/blur-shell/src/main/java/org/apache/blur/shell/ListPlatformCommandsCommand.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.blur.shell;
+
+import java.io.PrintWriter;
+import java.util.List;
+
+import jline.Terminal;
+import jline.console.ConsoleReader;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.TException;
+import org.apache.blur.thrift.generated.Blur;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.CommandDescriptor;
+
+public class ListPlatformCommandsCommand extends Command {
+  @Override
+  public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException,
TException,
+      BlurException {
+
+    List<CommandDescriptor> listInstalledCommands = client.listInstalledCommands();
+    ConsoleReader reader = getConsoleReader();
+    Terminal terminal = reader.getTerminal();
+    int width = terminal.getWidth();
+    int commandNameWidth = width / 4;
+    int descriptionWidth = width - commandNameWidth;
+    for (CommandDescriptor commandDescriptor : listInstalledCommands) {
+      String commandName = commandDescriptor.getCommandName() + " ";
+      out.print(addWhiteSpace(commandName, commandNameWidth));
+
+      String description = commandDescriptor.getDescription();
+      if (description == null) {
+        out.println("-");
+      } else {
+        description = description.trim();
+        while (description.length() > 0) {
+          int len = Math.min(descriptionWidth, description.length());
+          out.println(description.substring(0, len));
+          description = description.substring(len);
+          description = description.trim();
+          if (description.length() > 0) {
+            out.print(addWhiteSpace("", commandNameWidth));
+          }
+        }
+      }
+    }
+  }
+
+  @Override
+  public String description() {
+    return "List platform commands that are installed.";
+  }
+
+  @Override
+  public String usage() {
+    return "";
+  }
+
+  @Override
+  public String name() {
+    return "command-list";
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-shell/src/main/java/org/apache/blur/shell/Main.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/Main.java b/blur-shell/src/main/java/org/apache/blur/shell/Main.java
index 98c1ab3..6a21e44 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/Main.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/Main.java
@@ -18,10 +18,7 @@
 
 package org.apache.blur.shell;
 
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -42,11 +39,8 @@ import org.apache.blur.shell.Main.QuitCommand.QuitCommandException;
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thrift.BadConnectionException;
 import org.apache.blur.thrift.BlurClient;
-import org.apache.blur.thrift.BlurClientManager;
 import org.apache.blur.thrift.Connection;
-import org.apache.blur.thrift.commands.BlurCommand;
 import org.apache.blur.thrift.generated.Blur;
-import org.apache.blur.thrift.generated.Blur.Client;
 import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.Selector;
@@ -698,6 +692,8 @@ public class Main {
     register(builder, new RemoveShardServerCommand());
     register(builder, new OptimizeTableCommand());
     register(builder, new QueryCommand());
+    register(builder, new ListPlatformCommandsCommand());
+    register(builder, new DescribePlatformCommandCommand());
     commands = builder.build();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7db1e37e/blur-shell/src/main/java/org/apache/blur/shell/TableFirstArgCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/TableFirstArgCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/TableFirstArgCommand.java
index 19b9803..90757cf 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/TableFirstArgCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/TableFirstArgCommand.java
@@ -17,6 +17,6 @@
  */
 package org.apache.blur.shell;
 
-public interface TableFirstArgCommand {
+public interface TableFirstArgCommand extends FirstArgCommand {
 
 }


Mime
View raw message