Move InputProvider to top-level
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package org.springframework.shell;
|
||||
|
||||
/**
|
||||
* To be implemented by components able to provide a "line" of user input, whether interactively or by batch.
|
||||
*
|
||||
* @author Eric Bottard
|
||||
*/
|
||||
public interface InputProvider {
|
||||
|
||||
/**
|
||||
* Return text entered by user to invoke commands.
|
||||
*
|
||||
* <p>Returning {@literal null} indicates end of input, requesting shell exit.</p>
|
||||
*/
|
||||
Input readInput();
|
||||
}
|
||||
@@ -264,14 +264,4 @@ public class Shell implements CommandRegistry {
|
||||
return "".equals(result) ? null : result;
|
||||
}
|
||||
|
||||
public interface InputProvider {
|
||||
/**
|
||||
* Return text entered by user to invoke commands.
|
||||
*
|
||||
* <p>Returning {@literal null} indicates end of input, requesting shell exit.</p>
|
||||
*/
|
||||
Input readInput();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.springframework.shell.CompletionContext;
|
||||
import org.springframework.shell.CompletionProposal;
|
||||
import org.springframework.shell.ExitRequest;
|
||||
import org.springframework.shell.Input;
|
||||
import org.springframework.shell.InputProvider;
|
||||
import org.springframework.shell.ResultHandler;
|
||||
import org.springframework.shell.Shell;
|
||||
|
||||
@@ -179,7 +180,7 @@ class JLineShellAutoConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
public static class JLineInputProvider implements Shell.InputProvider {
|
||||
public static class JLineInputProvider implements InputProvider {
|
||||
|
||||
private final LineReader lineReader;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ShellTest {
|
||||
public MockitoRule mockitoRule = MockitoJUnit.rule();
|
||||
|
||||
@Mock
|
||||
private Shell.InputProvider inputProvider;
|
||||
private InputProvider inputProvider;
|
||||
|
||||
@Mock
|
||||
private ResultHandler resultHandler;
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.shell.ParameterResolver;
|
||||
import org.springframework.shell.Shell;
|
||||
|
||||
/**
|
||||
* Creates beans for standard commands.
|
||||
@@ -59,4 +60,11 @@ public class StandardCommandsAutoConfiguration {
|
||||
public Stacktrace stacktrace() {
|
||||
return new Stacktrace();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(Script.Command.class)
|
||||
@ConditionalOnProperty(prefix = "spring.shell.command.script", value = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
public Script script(Shell shell) {
|
||||
return new Script(shell);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user