Add command group and group output of help command

Resolves #135
This commit is contained in:
Roland Weisleder
2017-09-23 15:33:57 +02:00
parent b21a1f16f1
commit e4e6471f27
6 changed files with 93 additions and 27 deletions

View File

@@ -53,4 +53,11 @@ public @interface ShellMethod {
*/
String prefix() default "--";
/**
* The command group which this command belongs to. The command group is used when printing a list of
* commands to group related commands.
* @return name of the command group
*/
String group() default "";
}

View File

@@ -61,9 +61,10 @@ public class StandardMethodTargetRegistrar implements MethodTargetRegistrar {
if (keys.length == 0) {
keys = new String[] { Utils.unCamelify(method.getName()) };
}
String group = shellMapping.group();
for (String key : keys) {
Supplier<Availability> availabilityIndicator = findAvailabilityIndicator(keys, bean, method);
MethodTarget target = new MethodTarget(method, bean, shellMapping.value(), availabilityIndicator);
MethodTarget target = new MethodTarget(method, bean, shellMapping.value(), group, availabilityIndicator);
registry.register(key, target);
commands.put(key, target);
}