This commit is contained in:
Janne Valkealahti
2021-12-18 16:59:48 +00:00
parent f20b71a8c2
commit af838ca006
5 changed files with 18 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import org.jline.utils.AttributedStyle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.shell.jline.PromptProvider;
@@ -36,7 +35,7 @@ import org.springframework.shell.jline.PromptProvider;
public class SpringShellSample {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(SpringShellSample.class, args);
SpringApplication.run(SpringShellSample.class, args);
}
@Bean

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
package org.springframework.shell.samples.noautoconf;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.shell.SpringShellAutoConfiguration;
@@ -58,7 +57,7 @@ import org.springframework.shell.standard.commands.StandardCommandsAutoConfigura
public class NoAutoConf {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(NoAutoConf.class, args);
SpringApplication.run(NoAutoConf.class, args);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,6 +37,10 @@ class DomainObject {
DomainObject(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
@Component

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,15 +31,12 @@ public class DynamicCommands {
private boolean connected;
private boolean authenticated;
public Availability authenticateAvailability() {
return connected ? Availability.available() : Availability.unavailable("you are not connected");
}
@ShellMethod(value = "Authenticate with the system", group = "Dynamic Commands")
public void authenticate(String credentials) {
authenticated = "sesame".equals(credentials);
}
@ShellMethod(value = "Connect to the system", group = "Dynamic Commands")
@@ -57,8 +54,4 @@ public class DynamicCommands {
public String blowUp() {
return "Boom!";
}
private Availability dangerousAvailability() {
return connected && authenticated ? Availability.available() : Availability.unavailable("you failed to authenticate. Try 'sesame'.");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 the original author or authors.
* Copyright 2015-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
package org.springframework.shell.standard;
import static org.springframework.shell.Utils.unCamelify;
import java.lang.reflect.Array;
import java.lang.reflect.Executable;
import java.lang.reflect.Method;
@@ -37,6 +35,12 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.metadata.MethodDescriptor;
import javax.validation.metadata.ParameterDescriptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.ConversionService;
@@ -54,9 +58,7 @@ import org.springframework.util.Assert;
import org.springframework.util.ConcurrentReferenceHashMap;
import org.springframework.util.ObjectUtils;
import javax.validation.*;
import javax.validation.metadata.MethodDescriptor;
import javax.validation.metadata.ParameterDescriptor;
import static org.springframework.shell.Utils.unCamelify;
/**
* Default ParameterResolver implementation that supports the following features:
@@ -129,8 +131,6 @@ public class StandardParameterResolver implements ParameterResolver {
@Override
public ValueResult resolve(MethodParameter methodParameter, List<String> wordsBuffer) {
String prefix = prefixForMethod(methodParameter.getMethod());
List<String> words = wordsBuffer.stream().filter(w -> !w.isEmpty()).collect(Collectors.toList());
CacheKey cacheKey = new CacheKey(methodParameter.getMethod(), wordsBuffer);
@@ -526,14 +526,10 @@ public class StandardParameterResolver implements ParameterResolver {
private static class ParameterRawValue {
private CompletionContext context;
private Integer from;
private Integer to;
private Integer keyIndex;
/**
* The raw String value that got bound to a parameter.
*/