Rename ShellMethod.help() to value(), as it is the only mandatory attribute.

This commit is contained in:
Eric Bottard
2017-08-10 11:13:13 +02:00
parent 78f69d51e2
commit 5b07a1a89c
9 changed files with 22 additions and 22 deletions

View File

@@ -37,13 +37,13 @@ public @interface ShellMethod {
* The name(s) by which this method can be invoked via Spring Shell. If not specified, the actual method name
* will be used (turning camelCase humps into "-").
*/
String[] value() default {};
String[] key() default {};
/**
* A description for the command. Should not contain any formatting (e.g. html) characters and would typically
* start with a capital letter and end with a dot.
*/
String help() default "";
String value() default "";
/**
* The prefix to use for assigning parameters by name.

View File

@@ -50,12 +50,12 @@ public class StandardMethodTargetRegistrar implements MethodTargetRegistrar {
Class<?> clazz = bean.getClass();
ReflectionUtils.doWithMethods(clazz, method -> {
ShellMethod shellMapping = method.getAnnotation(ShellMethod.class);
String[] keys = shellMapping.value();
String[] keys = shellMapping.key();
if (keys.length == 0) {
keys = new String[] {method.getName()};
}
for (String key : keys) {
MethodTarget target = new MethodTarget(method, bean, shellMapping.help());
MethodTarget target = new MethodTarget(method, bean, shellMapping.value());
registry.register(key, target);
commands.put(key, target);
}

View File

@@ -39,29 +39,29 @@ public class Remote {
* <li>default value supplying (foo and bar)</li>
* </ul>
*/
@ShellMethod(help = "switch channels")
@ShellMethod(value = "switch channels")
public void zap(boolean force,
String name,
@ShellOption(defaultValue="defoolt") String foo,
@ShellOption(value = {"--bar", "--baz"}, defaultValue = "last") String bar) {
}
@ShellMethod(help = "bye bye")
@ShellMethod(value = "bye bye")
public void shutdown(@ShellOption Delay delay) {
}
@ShellMethod(help = "a different prefix", prefix = "-")
@ShellMethod(value = "a different prefix", prefix = "-")
public void prefixTest(@ShellOption String message) {
}
@ShellMethod(help = "add 3 numbers together")
@ShellMethod(value = "add 3 numbers together")
public void add(@ShellOption(arity = 3, valueProvider = NumberValueProvider.class) List<Integer> numbers) {
}
@ShellMethod(help = "add 3 numbers together (array)")
@ShellMethod(value = "add 3 numbers together (array)")
public void addAsArray(@ShellOption(arity = 3, valueProvider = NumberValueProvider.class) int[] numbers) {
}