]> source.dussan.org Git - gitblit.git/commitdiff
Improve dispatcher usage output
authorJames Moger <james.moger@gitblit.com>
Thu, 27 Mar 2014 19:51:12 +0000 (15:51 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 10 Apr 2014 23:00:05 +0000 (19:00 -0400)
src/main/java/com/gitblit/transport/ssh/commands/DispatchCommand.java

index 6e9a87ddf5908f3a28fb941b5d98be6c1ea0e291..f8239b551a85e45a0521b5e5a599bddcd33bdbb3 100644 (file)
@@ -318,6 +318,10 @@ public abstract class DispatchCommand extends BaseCommand implements ExtensionPo
                return false;
        }
 
+       public String getDescription() {
+               return getClass().getAnnotation(CommandMetaData.class).description();
+       }
+
        @Override
        public String usage() {
                Set<String> cmds = new TreeSet<String>();
@@ -351,6 +355,16 @@ public abstract class DispatchCommand extends BaseCommand implements ExtensionPo
                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()) {