Move InputProvider to top-level

This commit is contained in:
Eric Bottard
2017-08-09 17:43:46 +02:00
parent 885e22ea0f
commit a7d9ababa0
5 changed files with 27 additions and 12 deletions

View File

@@ -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();
}

View File

@@ -264,14 +264,4 @@ public class Shell implements CommandRegistry {
return "".equals(result) ? null : result; 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();
}
} }

View File

@@ -46,6 +46,7 @@ import org.springframework.shell.CompletionContext;
import org.springframework.shell.CompletionProposal; import org.springframework.shell.CompletionProposal;
import org.springframework.shell.ExitRequest; import org.springframework.shell.ExitRequest;
import org.springframework.shell.Input; import org.springframework.shell.Input;
import org.springframework.shell.InputProvider;
import org.springframework.shell.ResultHandler; import org.springframework.shell.ResultHandler;
import org.springframework.shell.Shell; 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; private final LineReader lineReader;

View File

@@ -45,7 +45,7 @@ public class ShellTest {
public MockitoRule mockitoRule = MockitoJUnit.rule(); public MockitoRule mockitoRule = MockitoJUnit.rule();
@Mock @Mock
private Shell.InputProvider inputProvider; private InputProvider inputProvider;
@Mock @Mock
private ResultHandler resultHandler; private ResultHandler resultHandler;

View File

@@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.shell.ParameterResolver; import org.springframework.shell.ParameterResolver;
import org.springframework.shell.Shell;
/** /**
* Creates beans for standard commands. * Creates beans for standard commands.
@@ -59,4 +60,11 @@ public class StandardCommandsAutoConfiguration {
public Stacktrace stacktrace() { public Stacktrace stacktrace() {
return new 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);
}
} }