use of org.apache.dubbo.qos.command.annotation.Cmd in project dubbo by alibaba.
the class Help method mainHelp.
/*
* output main help
*/
private String mainHelp() {
final TTable tTable = new TTable(new TTable.ColumnDefine[] { new TTable.ColumnDefine(TTable.Align.RIGHT), new TTable.ColumnDefine(80, false, TTable.Align.LEFT) });
final List<Class<?>> classes = CommandHelper.getAllCommandClass();
Collections.sort(classes, new Comparator<Class<?>>() {
@Override
public int compare(Class<?> o1, Class<?> o2) {
final Integer o1s = o1.getAnnotation(Cmd.class).sort();
final Integer o2s = o2.getAnnotation(Cmd.class).sort();
return o1s.compareTo(o2s);
}
});
for (Class<?> clazz : classes) {
if (clazz.isAnnotationPresent(Cmd.class)) {
final Cmd cmd = clazz.getAnnotation(Cmd.class);
tTable.addRow(cmd.name(), cmd.summary());
}
}
return tTable.padding(1).rendering();
}
use of org.apache.dubbo.qos.command.annotation.Cmd in project dubbo by alibaba.
the class Help method commandHelp.
private String commandHelp(String commandName) {
if (!CommandHelper.hasCommand(commandName)) {
return "no such command:" + commandName;
}
Class<?> clazz = CommandHelper.getCommandClass(commandName);
final Cmd cmd = clazz.getAnnotation(Cmd.class);
final TTable tTable = new TTable(new TTable.ColumnDefine[] { new TTable.ColumnDefine(TTable.Align.RIGHT), new TTable.ColumnDefine(80, false, TTable.Align.LEFT) });
tTable.addRow("COMMAND NAME", commandName);
if (null != cmd.example()) {
tTable.addRow("EXAMPLE", drawExample(cmd));
}
return tTable.padding(1).rendering();
}