private CompletionProposal toCommandProposal(String command, MethodTarget methodTarget) { return new CompletionProposal(command) .dontQuote(true) .category("Available commands") .description(methodTarget.getHelp()); }
/** * Main class that delegates to Spring Shell's Bootstrap class in order to simplify debugging inside an IDE */ public static void main(String[] args) throws IOException { Bootstrap.main(args); } }
private boolean isAvailable(MethodTarget methodTarget) { return methodTarget.getAvailability().isAvailable(); }
private List<ParameterDescription> getParameterDescriptions(MethodTarget methodTarget) { return Utils.createMethodParameters(methodTarget.getMethod()) .flatMap(mp -> parameterResolvers.stream().filter(pr -> pr.supports(mp)).limit(1L) .flatMap(pr -> pr.describe(mp))) .collect(Collectors.toList()); }
/** * Verifies that we have at least one {@link ParameterResolver} that supports each of the * {@link MethodParameter}s in the method. */ private void validateParameterResolvers(MethodTarget methodTarget) { Utils.createMethodParameters(methodTarget.getMethod()) .forEach(parameter -> { parameterResolvers.stream() .filter(resolver -> resolver.supports(parameter)) .findFirst() .orElseThrow(() -> new ParameterResolverMissingException(parameter)); }); }
private void documentAvailability(AttributedStringBuilder result, MethodTarget methodTarget) { Availability availability = methodTarget.getAvailability(); if (!availability.isAvailable()) { result.append("CURRENTLY UNAVAILABLE", AttributedStyle.BOLD).append("\n"); result.append('\t').append("This command is currently not available because ") .append(availability.getReason()) .append(".\n"); } }
@Override @SuppressWarnings("unchecked") public void handleResult(Iterable result) { for (Object o : result) { delegate.handleResult(o); } } }
public MethodTarget(Method method, Object bean, String help, Supplier<Availability> availabilityIndicator) { this(method, bean, new Help(help, null), availabilityIndicator); }
/** * Construct a MethodTarget for the unique method named {@literal name} on the given object. Fails with an exception * in case of overloaded method. */ public static MethodTarget of(String name, Object bean, Help help) { return of(name, bean, help, null); }
protected void createAndRegisterBeanDefinition(GenericApplicationContext annctx, Class<?> clazz) { createAndRegisterBeanDefinition(annctx, clazz, null); }
public static Availability available() { return new Availability(null); }
public String getHelp() { return help.getDescription(); }
public String getGroup() { return help.getGroup(); }
public static void main(String[] args) throws Exception { Bootstrap.main(args); } }
public MethodTarget(Method method, Object bean, String help) { this(method, bean, new Help(help, null), null); }
public static void main(String[] args) throws Exception { Bootstrap.main(args); } }
public static void main(String[] args) throws IOException { Bootstrap.main(args); }
public static void main(String[] args) throws Exception { Bootstrap.main(args); } }
public static void main(String[] args) throws Exception { Bootstrap.main(args); } }
public static void main(String[] args) throws IOException { Bootstrap.main(args); } }