Rename ShellMethod.help() to value(), as it is the only mandatory attribute.
This commit is contained in:
@@ -28,7 +28,7 @@ import org.springframework.shell.standard.ShellOption;
|
||||
@ShellComponent
|
||||
public class JCommanderCommands {
|
||||
|
||||
@ShellMethod(help = "bind parameters to JCommander POJO")
|
||||
@ShellMethod("Bind parameters to JCommander POJO.")
|
||||
public String jcommander(@ShellOption(optOut = true) Args args) {
|
||||
return "You said " + args;
|
||||
}
|
||||
|
||||
@@ -38,42 +38,42 @@ import org.springframework.stereotype.Component;
|
||||
@ShellComponent()
|
||||
public class Commands {
|
||||
|
||||
@ShellMethod(help = "a command whose name looks the same as another one", value = "help me out")
|
||||
@ShellMethod(value = "A command whose name looks the same as another one.", key = "help me out")
|
||||
public void helpMeOut() {
|
||||
System.out.println("You can go");
|
||||
}
|
||||
|
||||
@ShellMethod(help = "it's cool")
|
||||
@ShellMethod("It's cool.")
|
||||
public String foo(String bar) {
|
||||
return bar;
|
||||
}
|
||||
|
||||
@ShellMethod(help = "it's cool with a prefix", prefix = "-")
|
||||
@ShellMethod(value = "It's cool with a prefix.", prefix = "-")
|
||||
public String fooPrefix(String bar) {
|
||||
return bar;
|
||||
}
|
||||
|
||||
@ShellMethod(help = "Shows support for boolean parameters, with arity=0")
|
||||
@ShellMethod("Shows support for boolean parameters, with arity=0.")
|
||||
public void shutdown(@ShellOption(arity = 0) boolean force) {
|
||||
System.out.println("You passed " + force);
|
||||
}
|
||||
|
||||
@ShellMethod(help = "test completion of special values")
|
||||
@ShellMethod("Test completion of special values.")
|
||||
public void quote(@ShellOption(valueProvider = FunnyValuesProvider.class) String text) {
|
||||
System.out.println("You said " + text);
|
||||
}
|
||||
|
||||
@ShellMethod(help = "add stuff")
|
||||
@ShellMethod("Add stuff.")
|
||||
public int add(int ahbahdisdonc, int b, int c) {
|
||||
return ahbahdisdonc + b + c;
|
||||
}
|
||||
|
||||
@ShellMethod(help = "Fails with an exception")
|
||||
@ShellMethod("Fails with an exception.")
|
||||
public void fail(ElementType elementType) {
|
||||
throw new IllegalArgumentException("You said " + elementType);
|
||||
}
|
||||
|
||||
@ShellMethod(help = "add array numbers")
|
||||
@ShellMethod("Add array numbers.")
|
||||
public double addDoubles(@ShellOption(arity = 3) double[] numbers) {
|
||||
return Arrays.stream(numbers).sum();
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Clear {
|
||||
@Autowired @Lazy
|
||||
private Terminal terminal;
|
||||
|
||||
@ShellMethod(help = "Clear the shell screen.")
|
||||
@ShellMethod("Clear the shell screen.")
|
||||
public void clear() {
|
||||
terminal.puts(InfoCmp.Capability.clear_screen);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Help {
|
||||
this.commandRegistry = commandRegistry;
|
||||
}
|
||||
|
||||
@ShellMethod(help = "Display help about available commands.", prefix = "-")
|
||||
@ShellMethod(value = "Display help about available commands.", prefix = "-")
|
||||
public CharSequence help(
|
||||
@ShellOption(defaultValue = ShellOption.NULL,
|
||||
valueProvider = CommandValueProvider.class,
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Quit {
|
||||
*/
|
||||
public interface Command {}
|
||||
|
||||
@ShellMethod(help = "Exit the shell.", value = {"quit", "exit"})
|
||||
@ShellMethod(value = "Exit the shell.", key = {"quit", "exit"})
|
||||
public void quit() {
|
||||
throw new ExitRequest();
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Stacktrace {
|
||||
private ThrowableResultHandler throwableResultHandler;
|
||||
|
||||
|
||||
@ShellMethod(value = ThrowableResultHandler.DETAILS_COMMAND_NAME, help = "Display the full stacktrace of the last error")
|
||||
@ShellMethod(key = ThrowableResultHandler.DETAILS_COMMAND_NAME, value = "Display the full stacktrace of the last error")
|
||||
public void stacktrace() {
|
||||
if (throwableResultHandler.getLastError() != null) {
|
||||
throwableResultHandler.getLastError().printStackTrace(terminal.writer());
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user