James Moger
2014-04-13 6fbbfe057242e5a3d5b5b86f161fec93a282319e
src/main/java/com/gitblit/transport/ssh/commands/DispatchCommand.java
@@ -40,6 +40,12 @@
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
/**
 * Parses an SSH command-line and dispatches the command to the appropriate
 * BaseCommand instance.
 *
 * @since 1.5.0
 */
public abstract class DispatchCommand extends BaseCommand implements ExtensionPoint {
   private Logger log = LoggerFactory.getLogger(getClass());
@@ -89,6 +95,7 @@
    * registered within this method.
    *
    * @param user
    * @since 1.5.0
    */
   protected abstract void setup(UserModel user);
@@ -318,6 +325,10 @@
      return false;
   }
   public String getDescription() {
      return getClass().getAnnotation(CommandMetaData.class).description();
   }
   @Override
   public String usage() {
      Set<String> cmds = new TreeSet<String>();
@@ -351,6 +362,16 @@
      String format = "%-" + maxLength + "s   %s";
      final StringBuilder usage = new StringBuilder();
      if (!StringUtils.isEmpty(getName())) {
         String title = getName().toUpperCase() + ": " + getDescription();
         String b = com.gitblit.utils.StringUtils.leftPad("", title.length() + 2, '═');
         usage.append('\n');
         usage.append(b).append('\n');
         usage.append(' ').append(title).append('\n');
         usage.append(b).append('\n');
         usage.append('\n');
      }
      if (!cmds.isEmpty()) {
         usage.append("Available commands");
         if (!getName().isEmpty()) {