Remove legacy from sample
- Preparation for further work as remove shell 1.x dep from sample. - Relates #333
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<artifactId>spring-shell-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<description>Examples of using Spring Shell 2</description>
|
||||
|
||||
<build>
|
||||
@@ -27,28 +27,13 @@
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- The following starter brings everything you need, including adapters that trigger only if needed-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.shell</groupId>
|
||||
<artifactId>spring-shell-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Depend on Shell 1 to use Shell 1 API -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.shell</groupId>
|
||||
<artifactId>spring-shell</artifactId>
|
||||
<version>1.2.0.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Depend on JCommander to use JCommander API -->
|
||||
<dependency>
|
||||
<groupId>com.beust</groupId>
|
||||
<artifactId>jcommander</artifactId>
|
||||
<version>1.48</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 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
|
||||
*
|
||||
* https://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.samples.legacy;
|
||||
|
||||
/**
|
||||
* Enum used by some of the example Shell 1 commands.
|
||||
*
|
||||
* @author Eric Bottard
|
||||
*/
|
||||
public enum ArtifactType {
|
||||
|
||||
source, processor, sink, task
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 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
|
||||
*
|
||||
* https://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.samples.legacy;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.shell.core.CommandMarker;
|
||||
import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
|
||||
import org.springframework.shell.core.annotation.CliCommand;
|
||||
import org.springframework.shell.core.annotation.CliOption;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
public static final Method REGISTER_METHOD = ReflectionUtils.findMethod(LegacyCommands.class, "register", String.class, ArtifactType.class, String.class, boolean.class);
|
||||
public static final Method SUM_METHOD = ReflectionUtils.findMethod(LegacyCommands.class, "sum", int.class, int.class);
|
||||
|
||||
private boolean available = true;
|
||||
|
||||
@CliAvailabilityIndicator("register module")
|
||||
public boolean registerAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
@CliCommand(value = "register module", help = "Register a new module")
|
||||
public String register(
|
||||
@CliOption(mandatory = true,
|
||||
key = {"", "name"},
|
||||
help = "the name for the registered module")
|
||||
String name,
|
||||
@CliOption(mandatory = true,
|
||||
key = {"type"},
|
||||
help = "the type for the registered module")
|
||||
ArtifactType type,
|
||||
@CliOption(mandatory = false,
|
||||
key = {"coordinates", "coords"},
|
||||
help = "coordinates to the module archive")
|
||||
String coordinates,
|
||||
@CliOption(key = "force",
|
||||
help = "force update if module already exists (only if not in use)",
|
||||
specifiedDefaultValue = "true",
|
||||
unspecifiedDefaultValue = "false")
|
||||
boolean force) {
|
||||
return String.format(("Successfully registered module '%s:%s'"), type, name);
|
||||
}
|
||||
|
||||
@CliCommand(value = "sum", help = "adds two numbers. Will also toggle the 'register module' command availability")
|
||||
public int sum(
|
||||
@CliOption(key = "v1", unspecifiedDefaultValue = "38") int a,
|
||||
@CliOption(key = "v2", specifiedDefaultValue = "42") int b) {
|
||||
available = !available;
|
||||
return a + b;
|
||||
}
|
||||
|
||||
@CliCommand(value = "sum2", help = "adds two numbers")
|
||||
public int sum2(
|
||||
@CliOption(key = "v1", unspecifiedDefaultValue = "38") @Min(5) int a,
|
||||
@CliOption(key = "v2", specifiedDefaultValue = "42", mandatory = true) int b,
|
||||
@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;
|
||||
}
|
||||
|
||||
@CliCommand(value = "legacy-file", help = "Uses a legacy converter for completion")
|
||||
public String legacyFile(@CliOption(key = "file") File file, @CliOption(key = "flag") boolean flag) {
|
||||
return file + " exists? : " + file.exists();
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import org.springframework.shell.SpringShellAutoConfiguration;
|
||||
import org.springframework.shell.jcommander.JCommanderParameterResolverAutoConfiguration;
|
||||
import org.springframework.shell.jline.JLineShellAutoConfiguration;
|
||||
import org.springframework.shell.samples.jcommander.JCommanderCommands;
|
||||
import org.springframework.shell.samples.legacy.LegacyCommands;
|
||||
import org.springframework.shell.samples.standard.Commands;
|
||||
import org.springframework.shell.samples.standard.DynamicCommands;
|
||||
import org.springframework.shell.samples.standard.TableCommands;
|
||||
@@ -51,7 +50,6 @@ import org.springframework.shell.standard.commands.StandardCommandsAutoConfigura
|
||||
//PropertyPlaceholderAutoConfiguration.class,
|
||||
// Sample Commands
|
||||
JCommanderCommands.class,
|
||||
LegacyCommands.class,
|
||||
Commands.class,
|
||||
FileValueProvider.class,
|
||||
DynamicCommands.class,
|
||||
|
||||
Reference in New Issue
Block a user