Skip to content

Commit f701dd9

Browse files
czpilarfmbenhassine
authored andcommitted
Add JLine NonInteractiveShellRunner configuration
Resolves #1312 Signed-off-by: David Pilar <david@czpilar.net>
1 parent 9f35a7d commit f701dd9

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

spring-shell-core-autoconfigure/src/main/java/org/springframework/shell/core/autoconfigure/JLineShellAutoConfiguration.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.springframework.context.event.ContextClosedEvent;
4747
import org.springframework.context.event.EventListener;
4848
import org.springframework.core.env.Environment;
49+
import org.springframework.shell.core.NonInteractiveShellRunner;
4950
import org.springframework.shell.core.ShellRunner;
5051
import org.springframework.shell.core.command.Command;
5152
import org.springframework.shell.core.command.CommandParser;
@@ -67,6 +68,7 @@
6768
* @author Florent Biville
6869
* @author Mahmoud Ben Hassine
6970
* @author Piotr Olaszewski
71+
* @author David Pilar
7072
*/
7173
@AutoConfiguration
7274
@EnableConfigurationProperties(SpringShellProperties.class)
@@ -109,6 +111,13 @@ public ShellRunner jlineShellRunner(JLineInputProvider inputProvider, CommandPar
109111
return jLineShellRunner;
110112
}
111113

114+
@Bean
115+
@ConditionalOnProperty(prefix = "spring.shell.interactive", name = "enabled", havingValue = "false")
116+
public ShellRunner jlineNonInteractiveShellRunner(CommandParser commandParser, CommandRegistry commandRegistry,
117+
Terminal terminal) {
118+
return new NonInteractiveShellRunner(commandParser, commandRegistry, terminal.writer());
119+
}
120+
112121
@Bean
113122
public LineReader lineReader(Terminal terminal, Parser parser, CommandCompleter commandCompleter,
114123
CommandHighlighter commandHighlighter) {

spring-shell-core-autoconfigure/src/main/java/org/springframework/shell/core/autoconfigure/ShellRunnerAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public ShellRunner systemShellRunner(ConsoleInputProvider consoleInputProvider,
5353
}
5454

5555
@Bean
56+
@ConditionalOnMissingClass("org.springframework.shell.jline.DefaultJLineShellConfiguration")
5657
@ConditionalOnProperty(prefix = "spring.shell.interactive", name = "enabled", havingValue = "false")
5758
public ShellRunner nonInteractiveShellRunner(CommandParser commandParser, CommandRegistry commandRegistry) {
5859
return new NonInteractiveShellRunner(commandParser, commandRegistry);

0 commit comments

Comments
 (0)