Refactor packages and artifactIds to prepare for official migration to spring-projects repo.

Remove usage of component scan in favor of auto-conf

Fixes #61
This commit is contained in:
Eric Bottard
2017-08-03 18:06:28 +02:00
parent 5fd1f716d9
commit 6497df181d
91 changed files with 488 additions and 264 deletions

View File

@@ -10,13 +10,12 @@ while maintaining some level of backward compatibility with your existing comman
```
== Running
*Note:* the dummy commands that are currently available are not here to stay. Expect a more modular
setup in the future. In the meantime, to get a grasp of how the shell would behave, you can
The project comes with a sample application, showcasing the various ways you can write commands.
```
# if using a local snapshot version
./mvnw install
./mvnw -pl spring-shell2-samples spring-boot:run
./mvnw -pl spring-shell-samples spring-boot:run
```
From there, try typing `help` at the shell prompt.
From there, try typing `help` or `help <commmand>` at the shell prompt.

29
pom.xml
View File

@@ -3,7 +3,8 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<artifactId>spring-shell-parent</artifactId>
<name>Spring Shell Parent POM</name>
<version>2.0.0.BUILD-SNAPSHOT</version>
<packaging>pom</packaging>
@@ -20,13 +21,13 @@
</properties>
<modules>
<module>spring-shell2-core</module>
<module>spring-shell2-core-tests</module>
<module>spring-shell2-standard</module>
<module>spring-shell2-standard-commands</module>
<module>spring-shell2-jcommander-adapter</module>
<module>spring-shell2-samples</module>
<module>spring-shell2-shell1-adapter</module>
<module>spring-shell-core</module>
<module>spring-shell-core-test-support</module>
<module>spring-shell-standard</module>
<module>spring-shell-standard-commands</module>
<module>spring-shell-jcommander-adapter</module>
<module>spring-shell-samples</module>
<module>spring-shell-shell1-adapter</module>
</modules>
<dependencyManagement>
@@ -34,32 +35,32 @@
<!-- SUB MODULES -->
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core</artifactId>
<artifactId>spring-shell-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core-tests</artifactId>
<artifactId>spring-shell-core-test-support</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-standard</artifactId>
<artifactId>spring-shell-standard</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-standard-commands</artifactId>
<artifactId>spring-shell-standard-commands</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-shell1-adapter</artifactId>
<artifactId>spring-shell-shell1-adapter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-jcommander-adapter</artifactId>
<artifactId>spring-shell-jcommander-adapter</artifactId>
<version>${project.version}</version>
</dependency>
<!-- OTHER DEPS -->

View File

@@ -2,12 +2,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-shell2-core-tests</artifactId>
<artifactId>spring-shell-core-test-support</artifactId>
<name>Spring Shell Core Test Support</name>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<artifactId>spring-shell-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
@@ -16,7 +17,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core</artifactId>
<artifactId>spring-shell-core</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.Assertions;

View File

@@ -2,12 +2,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-shell2-core</artifactId>
<artifactId>spring-shell-core</artifactId>
<name>Spring Shell Core</name>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<artifactId>spring-shell-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
@@ -25,6 +26,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jline</groupId>

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.util.List;
import java.util.stream.Collectors;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.util.Map;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import org.jline.reader.ParsedLine;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.util.ArrayList;
import java.util.List;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
/**
* Represents a proposal for TAB completion, made not only of the text to append, but also metadata about the proposal.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
/**
* This exception, when thrown and caught, will ask the shell to gracefully shutdown.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.util.Arrays;
import java.util.Collections;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.lang.reflect.Method;
import java.util.HashSet;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.util.Map;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.util.Collections;
import java.util.List;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
/**
* Thrown by a {@link ParameterResolver} when a parameter that should have been set has been left out altogether.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.util.List;
import java.util.stream.Stream;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
/**
* Implementations know how to deal with results of method invocations, whether normal results or exceptions thrown.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.io.IOException;
import java.lang.reflect.Method;
@@ -33,6 +33,8 @@ import javax.validation.Validation;
import javax.validation.executable.ExecutableValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.core.MethodParameter;
import org.springframework.util.ReflectionUtils;

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.shell;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.shell.jline.JLineShell;
import org.springframework.shell.result.ResultHandlerConfig;
/**
* Creates supporting beans for running the Shell
*/
@Configuration
@ComponentScan(basePackageClasses = ResultHandlerConfig.class)
@Import(JLineShell.class)
public class SpringShellAutoConfiguration {
@Bean
@ConditionalOnMissingBean(ConversionService.class)
public ConversionService conversionService() {
return new DefaultConversionService();
}
@Bean
public ApplicationRunner applicationRunner(Shell shell) {
return new ApplicationRunner() {
@Override
public void run(ApplicationArguments args) throws Exception {
shell.run();
}
};
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
/**
* Thrown during parameter resolution, when a parameter has been identified, but could not be correctly resolved.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.lang.reflect.Constructor;
import java.lang.reflect.Executable;
@@ -78,6 +78,9 @@ public class Utils {
return methodParameter;
}
/**
* Return MethodParameters for each parameter of the given method/constructor.
*/
public static Stream<MethodParameter> createMethodParameters(Executable executable) {
return IntStream.range(0, executable.getParameterCount())
.mapToObj(i -> createMethodParameter(executable, i));

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.util.BitSet;
import java.util.List;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.jline;
package org.springframework.shell.jline;
import java.util.Collections;
import java.util.LinkedList;
@@ -26,7 +26,7 @@ import org.jline.reader.EOFError;
import org.jline.reader.ParsedLine;
import org.jline.reader.Parser;
import org.springframework.shell2.CompletingParsedLine;
import org.springframework.shell.CompletingParsedLine;
/**
* Shameful copy-paste of JLine's {@link org.jline.reader.impl.DefaultParser} which

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.jline;
package org.springframework.shell.jline;
import java.io.IOException;
import java.util.List;
@@ -40,13 +40,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.shell2.CompletingParsedLine;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell2.ExitRequest;
import org.springframework.shell2.Input;
import org.springframework.shell2.ResultHandler;
import org.springframework.shell2.Shell;
import org.springframework.shell.CompletingParsedLine;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
import org.springframework.shell.ExitRequest;
import org.springframework.shell.Input;
import org.springframework.shell.ResultHandler;
import org.springframework.shell.Shell;
/**
* Shell implementation using JLine to capture input and trigger completions.

View File

@@ -14,13 +14,11 @@
* limitations under the License.
*/
package org.springframework.shell2.result;
package org.springframework.shell.result;
import org.jline.terminal.Terminal;
import org.jline.utils.AttributedCharSequence;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell2.ResultHandler;
import org.springframework.shell.ResultHandler;
import org.springframework.stereotype.Component;
/**

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package org.springframework.shell2.result;
package org.springframework.shell.result;
import org.jline.utils.AttributedString;
import org.jline.utils.AttributedStyle;
import org.springframework.shell2.CommandNotFound;
import org.springframework.shell2.ResultHandler;
import org.springframework.shell.CommandNotFound;
import org.springframework.shell.ResultHandler;
import org.springframework.stereotype.Component;
/**

View File

@@ -14,9 +14,9 @@
* limitations under the License.
*/
package org.springframework.shell2.result;
package org.springframework.shell.result;
import org.springframework.shell2.ResultHandler;
import org.springframework.shell.ResultHandler;
import org.springframework.stereotype.Component;
/**

View File

@@ -14,19 +14,19 @@
* limitations under the License.
*/
package org.springframework.shell2.result;
package org.springframework.shell.result;
import java.io.Closeable;
import java.io.IOException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.shell2.ExitRequest;
import org.springframework.shell2.ResultHandler;
import org.springframework.shell.ExitRequest;
import org.springframework.shell.ResultHandler;
import org.springframework.stereotype.Component;
/**
* Intercepts {@link org.springframework.shell2.ExitRequest} exceptions and gracefully exits the running process.
* Intercepts {@link org.springframework.shell.ExitRequest} exceptions and gracefully exits the running process.
*
* @author Eric Bottard
*/

View File

@@ -14,10 +14,9 @@
* limitations under the License.
*/
package org.springframework.shell2.result;
package org.springframework.shell.result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell2.ResultHandler;
import org.springframework.shell.ResultHandler;
import org.springframework.stereotype.Component;
/**

View File

@@ -14,17 +14,17 @@
* limitations under the License.
*/
package org.springframework.shell2.result;
package org.springframework.shell.result;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.shell2.ResultHandler;
import org.springframework.shell.ResultHandler;
/**
* Used for explicit configuration of {@link org.springframework.shell2.ResultHandler}s.
* Used for explicit configuration of {@link org.springframework.shell.ResultHandler}s.
*
* @author Eric Bottard
*/

View File

@@ -14,11 +14,12 @@
* limitations under the License.
*/
package org.springframework.shell2.result;
package org.springframework.shell.result;
import org.jline.terminal.Terminal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
/**
* Base class for ResultHandlers that rely on JLine's {@link Terminal}.
@@ -28,7 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public abstract class TerminalAwareResultHandler {
protected Terminal terminal;
@Autowired
@Autowired @Lazy
public void setTerminal(Terminal terminal) {
this.terminal = terminal;
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.result;
package org.springframework.shell.result;
import org.jline.utils.AttributedString;
import org.jline.utils.AttributedStringBuilder;
@@ -22,8 +22,8 @@ import org.jline.utils.AttributedStyle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.shell2.CommandRegistry;
import org.springframework.shell2.ResultHandler;
import org.springframework.shell.CommandRegistry;
import org.springframework.shell.ResultHandler;
import org.springframework.stereotype.Component;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.result;
package org.springframework.shell.result;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -23,8 +23,7 @@ import java.util.Map;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell2.ResultHandler;
import org.springframework.stereotype.Component;
import org.springframework.shell.ResultHandler;
/**
* A delegating {@link ResultHandler} that dispatches handling based on the type of the result.

View File

@@ -19,4 +19,4 @@
*
* @author Eric Bottard
*/
package org.springframework.shell2.result;
package org.springframework.shell.result;

View File

@@ -0,0 +1,3 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.shell.SpringShellAutoConfiguration,\
org.springframework.shell.jline.JLineShell

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import java.io.IOException;
import java.util.Arrays;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -2,12 +2,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-shell2-jcommander-adapter</artifactId>
<artifactId>spring-shell-jcommander-adapter</artifactId>
<name>Spring Shell JCommander Adapter</name>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<artifactId>spring-shell-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
@@ -16,7 +17,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core</artifactId>
<artifactId>spring-shell-core</artifactId>
</dependency>
<dependency>
<groupId>com.beust</groupId>
@@ -26,6 +27,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>

View File

@@ -14,9 +14,9 @@
* limitations under the License.
*/
package org.springframework.shell2.jcommander;
package org.springframework.shell.jcommander;
import static org.springframework.shell2.Utils.unCamelify;
import static org.springframework.shell.Utils.unCamelify;
import java.lang.annotation.Annotation;
import java.util.Arrays;
@@ -29,11 +29,11 @@ import java.util.stream.Stream;
import org.springframework.beans.BeanUtils;
import org.springframework.core.MethodParameter;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell2.ParameterDescription;
import org.springframework.shell2.ParameterResolver;
import org.springframework.shell2.ValueResult;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
import org.springframework.shell.ParameterDescription;
import org.springframework.shell.ParameterResolver;
import org.springframework.shell.ValueResult;
import org.springframework.stereotype.Component;
import org.springframework.util.ReflectionUtils;
@@ -48,7 +48,6 @@ import com.beust.jcommander.ParametersDelegate;
*
* @author Eric Bottard
*/
@Component
public class JCommanderParameterResolver implements ParameterResolver {
private static final Collection<Class<? extends Annotation>> JCOMMANDER_ANNOTATIONS =

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.shell.jcommander;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Bean;
/**
* Registers JCommanderParameterResolver and supporting beans as appropriate.
*
* @author Eric Bottard
*/
@Configuration
public class JCommanderParameterResolverAutoConfiguration {
@Bean
public JCommanderParameterResolver jCommanderParameterResolver() {
return new JCommanderParameterResolver();
}
}

View File

@@ -19,4 +19,4 @@
*
* @author Eric Bottard
*/
package org.springframework.shell2.jcommander;
package org.springframework.shell.jcommander;

View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.shell.jcommander.JCommanderParameterResolverAutoConfiguration

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.jcommander;
package org.springframework.shell.jcommander;
import java.util.ArrayList;
import java.util.List;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.jcommander;
package org.springframework.shell.jcommander;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
@@ -25,14 +25,13 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Stream;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.springframework.core.MethodParameter;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell2.ParameterDescription;
import org.springframework.shell2.Utils;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
import org.springframework.shell.ParameterDescription;
import org.springframework.shell.Utils;
import org.springframework.util.ReflectionUtils;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.jcommander;
package org.springframework.shell.jcommander;
/**
* An hypothetical command class, with one method using JCommander args, and the other not.

View File

@@ -2,12 +2,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-shell2-samples</artifactId>
<artifactId>spring-shell-samples</artifactId>
<name>Spring Shell Samples</name>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<artifactId>spring-shell-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
@@ -19,7 +20,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>org.springframework.shell2.Bootstrap</mainClass>
<mainClass>org.springframework.shell.samples.SpringShellSample</mainClass>
</configuration>
</plugin>
</plugins>
@@ -28,24 +29,24 @@
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core</artifactId>
<artifactId>spring-shell-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-standard</artifactId>
<artifactId>spring-shell-standard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-standard-commands</artifactId>
<artifactId>spring-shell-standard-commands</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-shell1-adapter</artifactId>
<artifactId>spring-shell-shell1-adapter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-jcommander-adapter</artifactId>
<artifactId>spring-shell-jcommander-adapter</artifactId>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 the original author or authors.
* Copyright 2017 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.
@@ -14,14 +14,20 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell.samples;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.shell.Shell;
import org.springframework.shell.jline.JLineShell;
import org.springframework.shell.result.ResultHandlerConfig;
/**
* Main entry point for the application.
@@ -29,19 +35,11 @@ import org.springframework.core.convert.support.DefaultConversionService;
* <p>Creates the application context and start the REPL.</p>
*
* @author Eric Bottard
* @author Camilo Gonzalez
*/
@SpringBootApplication
public class Bootstrap {
public class SpringShellSample {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(Bootstrap.class);
context.getBean(Shell.class).run();
ConfigurableApplicationContext context = SpringApplication.run(SpringShellSample.class);
}
@Bean
public ConversionService conversionService() {
return new DefaultConversionService();
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.samples.jcommander;
package org.springframework.shell.samples.jcommander;
import java.util.ArrayList;
import java.util.List;

View File

@@ -14,11 +14,11 @@
* limitations under the License.
*/
package org.springframework.shell2.samples.jcommander;
package org.springframework.shell.samples.jcommander;
import org.springframework.shell2.standard.ShellComponent;
import org.springframework.shell2.standard.ShellMethod;
import org.springframework.shell2.standard.ShellOption;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellOption;
/**
* A class with JCommander commands.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.samples.legacy;
package org.springframework.shell.samples.legacy;
/**
* Created by ericbottard on 09/12/15.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.samples.legacy;
package org.springframework.shell.samples.legacy;
import java.lang.reflect.Method;
@@ -25,7 +25,9 @@ import org.springframework.stereotype.Component;
import org.springframework.util.ReflectionUtils;
/**
* Created by ericbottard on 09/12/15.
* A sample of legacy Shell 1 commands that can be run thanks to the legacy adapter.
*
* @author Eric Bottard
*/
@Component
public class LegacyCommands implements CommandMarker {
@@ -69,12 +71,12 @@ public class LegacyCommands implements CommandMarker {
@CliOption(key = "v3", mandatory = false) int c) {
return a + b + c;
}
@CliCommand(value = "legacy-echo", help = "Echoes a message")
public String legacyEcho(@CliOption(key = "", mandatory = true) String message) {
return message;
}
@CliCommand(value = "optional-echo", help = "Echoes an optional message")
public String optionalEcho(@CliOption(key = "", mandatory = false) String message) {
return message;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.samples.standard;
package org.springframework.shell.samples.standard;
import java.lang.annotation.ElementType;
import java.util.Arrays;
@@ -22,12 +22,12 @@ import java.util.List;
import java.util.stream.Collectors;
import org.springframework.core.MethodParameter;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell2.standard.ShellComponent;
import org.springframework.shell2.standard.ShellMethod;
import org.springframework.shell2.standard.ShellOption;
import org.springframework.shell2.standard.ValueProviderSupport;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellOption;
import org.springframework.shell.standard.ValueProviderSupport;
import org.springframework.stereotype.Component;
/**
@@ -80,7 +80,7 @@ public class Commands {
}
/**
* A {@link org.springframework.shell2.standard.ValueProvider} that emits values with special characters
* A {@link org.springframework.shell.standard.ValueProvider} that emits values with special characters
* (quotes, escapes, <em>etc.</em>)
*
* @author Eric Bottard

View File

@@ -2,12 +2,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-shell2-shell1-adapter</artifactId>
<artifactId>spring-shell-shell1-adapter</artifactId>
<name>Spring Shell 1 Adapter</name>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<artifactId>spring-shell-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
@@ -16,8 +17,10 @@
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core</artifactId>
<artifactId>spring-shell-core</artifactId>
</dependency>
<!-- The following dependency is Spring Shell 1. Note the spring-shell artifactId is not used by Shell 2-->
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell</artifactId>
@@ -26,10 +29,11 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core-tests</artifactId>
<artifactId>spring-shell-core-test-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.shell2.legacy;
package org.springframework.shell.legacy;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.shell.converters.ArrayConverter;
@@ -31,6 +32,16 @@ import org.springframework.shell.converters.SimpleFileConverter;
@ComponentScan(basePackageClasses = {ArrayConverter.class}, excludeFilters = @ComponentScan.Filter(
type = FilterType.ASSIGNABLE_TYPE,
value = {AvailableCommandsConverter.class, SimpleFileConverter.class}))
public class LegacyConfiguration {
public class LegacyAdapterAutoConfiguration {
@Bean
public LegacyMethodTargetResolver legacyMethodTargetResolver() {
return new LegacyMethodTargetResolver();
}
@Bean
public LegacyParameterResolver legacyParameterResolver() {
return new LegacyParameterResolver();
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.legacy;
package org.springframework.shell.legacy;
import static org.springframework.util.StringUtils.collectionToDelimitedString;
@@ -25,8 +25,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.shell2.MethodTarget;
import org.springframework.shell2.MethodTargetResolver;
import org.springframework.shell.MethodTarget;
import org.springframework.shell.MethodTargetResolver;
import org.springframework.stereotype.Component;
import org.springframework.util.ReflectionUtils;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.legacy;
package org.springframework.shell.legacy;
import java.lang.reflect.Parameter;
import java.util.ArrayList;
@@ -33,11 +33,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.shell.core.Converter;
import org.springframework.shell.core.annotation.CliOption;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell2.ParameterDescription;
import org.springframework.shell2.ParameterResolver;
import org.springframework.shell2.ValueResult;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
import org.springframework.shell.ParameterDescription;
import org.springframework.shell.ParameterResolver;
import org.springframework.shell.ValueResult;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

View File

@@ -17,4 +17,4 @@
/**
* Provides integration with Spring Shell 1.
*/
package org.springframework.shell2.legacy;
package org.springframework.shell.legacy;

View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.shell.legacy.LegacyAdapterAutoConfiguration

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.legacy;
package org.springframework.shell.legacy;
/**
* Created by ericbottard on 09/12/15.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.legacy;
package org.springframework.shell.legacy;
import java.lang.reflect.Method;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.legacy;
package org.springframework.shell.legacy;
import static org.assertj.core.api.Assertions.assertThat;
@@ -27,8 +27,8 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.shell2.MethodTarget;
import org.springframework.shell2.MethodTargetResolver;
import org.springframework.shell.MethodTarget;
import org.springframework.shell.MethodTargetResolver;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

View File

@@ -14,12 +14,12 @@
* limitations under the License.
*/
package org.springframework.shell2.legacy;
package org.springframework.shell.legacy;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.shell2.ValueResultAsserts.assertThat;
import static org.springframework.shell2.legacy.LegacyCommands.REGISTER_METHOD;
import static org.springframework.shell.ValueResultAsserts.assertThat;
import static org.springframework.shell.legacy.LegacyCommands.REGISTER_METHOD;
import org.junit.Rule;
import org.junit.Test;
@@ -34,10 +34,10 @@ import org.springframework.shell.converters.EnumConverter;
import org.springframework.shell.converters.StringConverter;
import org.springframework.shell.core.Converter;
import org.springframework.shell.core.annotation.CliOption;
import org.springframework.shell2.ParameterDescription;
import org.springframework.shell2.ParameterResolver;
import org.springframework.shell2.Utils;
import org.springframework.shell2.ValueResult;
import org.springframework.shell.ParameterDescription;
import org.springframework.shell.ParameterResolver;
import org.springframework.shell.Utils;
import org.springframework.shell.ValueResult;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

View File

@@ -2,12 +2,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-shell2-standard-commands</artifactId>
<artifactId>spring-shell-standard-commands</artifactId>
<name>Spring Shell Standard Commands</name>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<artifactId>spring-shell-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
@@ -15,11 +16,12 @@
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-standard</artifactId>
<artifactId>spring-shell-standard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jline</groupId>

View File

@@ -14,14 +14,15 @@
* limitations under the License.
*/
package org.springframework.shell2.standard.commands;
package org.springframework.shell.standard.commands;
import org.jline.terminal.Terminal;
import org.jline.utils.InfoCmp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell2.standard.ShellComponent;
import org.springframework.shell2.standard.ShellMethod;
import org.springframework.context.annotation.Lazy;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
/**
* ANSI console related commands.
@@ -31,7 +32,7 @@ import org.springframework.shell2.standard.ShellMethod;
@ShellComponent
public class Console {
@Autowired
@Autowired @Lazy
private Terminal terminal;
@ShellMethod(help = "Clear the shell screen.")

View File

@@ -14,14 +14,12 @@
* limitations under the License.
*/
package org.springframework.shell2.standard.commands;
package org.springframework.shell.standard.commands;
import static java.util.stream.Collectors.mapping;
import static java.util.stream.Collectors.toCollection;
import java.io.IOException;
import java.lang.reflect.Parameter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
@@ -33,16 +31,15 @@ import org.jline.utils.AttributedStringBuilder;
import org.jline.utils.AttributedStyle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.shell2.MethodTarget;
import org.springframework.shell2.ParameterDescription;
import org.springframework.shell2.ParameterResolver;
import org.springframework.shell2.CommandRegistry;
import org.springframework.shell2.standard.CommandValueProvider;
import org.springframework.shell2.standard.ShellComponent;
import org.springframework.shell2.standard.ShellMethod;
import org.springframework.shell2.standard.ShellOption;
import org.springframework.shell2.Utils;
import org.springframework.shell.MethodTarget;
import org.springframework.shell.ParameterDescription;
import org.springframework.shell.ParameterResolver;
import org.springframework.shell.CommandRegistry;
import org.springframework.shell.standard.CommandValueProvider;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellOption;
import org.springframework.shell.Utils;
/**
* A command to display help about all available commands.

View File

@@ -14,11 +14,11 @@
* limitations under the License.
*/
package org.springframework.shell2.standard.commands;
package org.springframework.shell.standard.commands;
import org.springframework.shell2.ExitRequest;
import org.springframework.shell2.standard.ShellComponent;
import org.springframework.shell2.standard.ShellMethod;
import org.springframework.shell.ExitRequest;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
/**
* A command that terminates the running shell.

View File

@@ -14,14 +14,15 @@
* limitations under the License.
*/
package org.springframework.shell2.standard.commands;
package org.springframework.shell.standard.commands;
import org.jline.terminal.Terminal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell2.result.ThrowableResultHandler;
import org.springframework.shell2.standard.ShellComponent;
import org.springframework.shell2.standard.ShellMethod;
import org.springframework.context.annotation.Lazy;
import org.springframework.shell.result.ThrowableResultHandler;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
/**
* A command to display the full stacktrace when an error occurs.
@@ -29,7 +30,7 @@ import org.springframework.shell2.standard.ShellMethod;
@ShellComponent
public class Stacktrace {
@Autowired
@Autowired @Lazy
private Terminal terminal;
@Autowired

View File

@@ -0,0 +1,52 @@
/*
* Copyright 2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.shell.standard.commands;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.shell.ParameterResolver;
/**
* Creates beans for standard commands.
*
* @author Eric Bottard
*/
@Configuration
public class StandardCommandsAutoConfiguration {
@Bean
public Help help(List<ParameterResolver> parameterResolvers) {
return new Help(parameterResolvers);
}
@Bean
public Console console() {
return new Console();
}
@Bean
public Quit quit() {
return new Quit();
}
@Bean
public Stacktrace stacktrace() {
return new Stacktrace();
}
}

View File

@@ -19,4 +19,4 @@
*
* @author Eric Bottard
*/
package org.springframework.shell2.standard.commands;
package org.springframework.shell.standard.commands;

View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.shell.standard.commands.StandardCommandsAutoConfiguration

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.standard.commands;
package org.springframework.shell.standard.commands;
import java.io.IOException;
import java.io.InputStream;
@@ -35,13 +35,13 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.io.ClassPathResource;
import org.springframework.shell2.standard.StandardParameterResolver;
import org.springframework.shell2.MethodTarget;
import org.springframework.shell2.ParameterResolver;
import org.springframework.shell2.CommandRegistry;
import org.springframework.shell2.standard.ShellComponent;
import org.springframework.shell2.standard.ShellMethod;
import org.springframework.shell2.standard.ShellOption;
import org.springframework.shell.standard.StandardParameterResolver;
import org.springframework.shell.MethodTarget;
import org.springframework.shell.ParameterResolver;
import org.springframework.shell.CommandRegistry;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellOption;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.FileCopyUtils;

View File

@@ -2,12 +2,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-shell2-standard</artifactId>
<artifactId>spring-shell-standard</artifactId>
<name>Spring Shell Standard API</name>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<artifactId>spring-shell-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
@@ -15,15 +16,16 @@
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core</artifactId>
<artifactId>spring-shell-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core-tests</artifactId>
<artifactId>spring-shell-core-test-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import java.util.List;
import java.util.stream.Collectors;
@@ -22,9 +22,9 @@ import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.MethodParameter;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell2.CommandRegistry;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
import org.springframework.shell.CommandRegistry;
import org.springframework.stereotype.Component;
/**

View File

@@ -14,14 +14,14 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import java.util.ArrayList;
import java.util.List;
import org.springframework.core.MethodParameter;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
import org.springframework.stereotype.Component;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@@ -69,7 +69,7 @@ public @interface ShellOption {
/**
* Used to indicate to the framework that the given parameter should NOT be resolved by
* {@link StandardParameterResolver}. This is useful if several implementations of
* {@link org.springframework.shell2.ParameterResolver} are present, given that the standard one can work with no
* {@link org.springframework.shell.ParameterResolver} are present, given that the standard one can work with no
* annotation at all.
*/
boolean optOut() default false;

View File

@@ -0,0 +1,53 @@
/*
* Copyright 2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.shell.standard;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.ConversionService;
import org.springframework.shell.CommandRegistry;
import org.springframework.shell.MethodTargetResolver;
import org.springframework.shell.ParameterResolver;
/**
* Sets up all required beans for supporting the standard Shell API.
*
* @author Eric Bottard
*/
@Configuration
public class StandardAPIAutoConfiguration {
@Bean
public ValueProvider commandValueProvider(CommandRegistry commandRegistry) {
return new CommandValueProvider(commandRegistry);
}
@Bean
public ValueProvider enumValueProvider() {
return new EnumValueProvider();
}
@Bean
public MethodTargetResolver standardMethodTargetResolver() {
return new StandardMethodTargetResolver();
}
@Bean
public ParameterResolver standardParameterResolver(ConversionService conversionService) {
return new StandardParameterResolver(conversionService);
}
}

View File

@@ -14,9 +14,8 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import static org.springframework.util.StringUtils.collectionToCommaDelimitedString;
import static org.springframework.util.StringUtils.collectionToDelimitedString;
import java.util.HashMap;
@@ -24,12 +23,10 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.shell2.MethodTarget;
import org.springframework.shell2.MethodTargetResolver;
import org.springframework.shell.MethodTarget;
import org.springframework.shell.MethodTargetResolver;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
/**
* The standard implementation of {@link MethodTargetResolver} for new shell applications,
@@ -39,7 +36,6 @@ import org.springframework.util.StringUtils;
* @author Florent Biville
* @author Camilo Gonzalez
*/
@Component
public class StandardMethodTargetResolver implements MethodTargetResolver {
@Autowired

View File

@@ -14,9 +14,9 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import static org.springframework.shell2.Utils.unCamelify;
import static org.springframework.shell.Utils.unCamelify;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
@@ -40,14 +40,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell2.ParameterDescription;
import org.springframework.shell2.ParameterMissingResolutionException;
import org.springframework.shell2.ParameterResolver;
import org.springframework.shell2.UnfinishedParameterResolutionException;
import org.springframework.shell2.Utils;
import org.springframework.shell2.ValueResult;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
import org.springframework.shell.ParameterDescription;
import org.springframework.shell.ParameterMissingResolutionException;
import org.springframework.shell.ParameterResolver;
import org.springframework.shell.UnfinishedParameterResolutionException;
import org.springframework.shell.Utils;
import org.springframework.shell.ValueResult;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.ConcurrentReferenceHashMap;

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import java.util.List;
import org.springframework.core.MethodParameter;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
/**
*/

View File

@@ -14,10 +14,10 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import org.springframework.core.MethodParameter;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell.CompletionContext;
/**
* Base class for {@link ValueProvider} that match by type. Subclasses {@literal C} will be selected for parameters

View File

@@ -19,4 +19,4 @@
*
* @author Eric Bottard
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;

View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.shell.standard.StandardAPIAutoConfiguration

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import static org.assertj.core.api.Assertions.assertThat;
@@ -32,11 +32,11 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.core.MethodParameter;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell2.MethodTarget;
import org.springframework.shell2.CommandRegistry;
import org.springframework.shell2.Utils;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
import org.springframework.shell.MethodTarget;
import org.springframework.shell.CommandRegistry;
import org.springframework.shell.Utils;
import org.springframework.util.ReflectionUtils;
/**

View File

@@ -14,16 +14,15 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.core.MethodParameter;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
/**
* An example commands class.

View File

@@ -14,12 +14,12 @@
* limitations under the License.
*/
package org.springframework.shell2.standard;
package org.springframework.shell.standard;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.shell2.ValueResultAsserts.assertThat;
import static org.springframework.shell.ValueResultAsserts.assertThat;
import static org.springframework.util.ReflectionUtils.findMethod;
import java.lang.reflect.Method;
@@ -32,12 +32,12 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.shell2.CompletionContext;
import org.springframework.shell2.CompletionProposal;
import org.springframework.shell2.ParameterMissingResolutionException;
import org.springframework.shell2.UnfinishedParameterResolutionException;
import org.springframework.shell2.Utils;
import org.springframework.shell2.ValueResult;
import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal;
import org.springframework.shell.ParameterMissingResolutionException;
import org.springframework.shell.UnfinishedParameterResolutionException;
import org.springframework.shell.Utils;
import org.springframework.shell.ValueResult;
/**
* Unit tests for DefaultParameterResolver.
@@ -220,8 +220,8 @@ public class StandardParameterResolverTest {
resolver.setValueProviders(singletonList(new Remote.NumberValueProvider("12", "42", "7")));
Method[] methods = {
findMethod(org.springframework.shell2.standard.Remote.class, "add", List.class),
findMethod(org.springframework.shell2.standard.Remote.class, "addAsArray", int[].class),
findMethod(org.springframework.shell.standard.Remote.class, "add", List.class),
findMethod(org.springframework.shell.standard.Remote.class, "addAsArray", int[].class),
};
for (Method method : methods) {
List<String> completions = resolver