diff options
author | James Moger <james.moger@gitblit.com> | 2014-03-27 15:51:12 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-04-10 19:00:05 -0400 |
commit | d40be7e468e4455a5f0ec3bbfee36314a61d9b27 (patch) | |
tree | 631bd73fe0e5c1e34b73fe9e2eab5f478eb8c5c8 /src/main/java/com/gitblit/transport | |
parent | fc8487e5ade37a82e686f4168ea5702bde3cdb4b (diff) | |
download | gitblit-d40be7e468e4455a5f0ec3bbfee36314a61d9b27.tar.gz gitblit-d40be7e468e4455a5f0ec3bbfee36314a61d9b27.zip |
Improve dispatcher usage output
Diffstat (limited to 'src/main/java/com/gitblit/transport')
-rw-r--r-- | src/main/java/com/gitblit/transport/ssh/commands/DispatchCommand.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/transport/ssh/commands/DispatchCommand.java b/src/main/java/com/gitblit/transport/ssh/commands/DispatchCommand.java index 6e9a87dd..f8239b55 100644 --- a/src/main/java/com/gitblit/transport/ssh/commands/DispatchCommand.java +++ b/src/main/java/com/gitblit/transport/ssh/commands/DispatchCommand.java @@ -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()) { |