Skip to content

Commit a0ed6d4

Browse files
committed
Make interactive mode the default
Closes: gh-1186 Signed-off-by: Andrey Litvitski <[email protected]>
1 parent 328f23a commit a0ed6d4

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ public static class NonePrimaryCommandConfiguration {
6161

6262
@Bean
6363
@ConditionalOnProperty(prefix = "spring.shell.interactive", value = "enabled", havingValue = "true",
64-
matchIfMissing = false)
64+
matchIfMissing = true)
6565
public InteractiveShellRunner interactiveApplicationRunner(LineReader lineReader, PromptProvider promptProvider,
6666
Shell shell, ShellContext shellContext) {
6767
return new InteractiveShellRunner(lineReader, promptProvider, shell, shellContext);
6868
}
6969

7070
@Bean
7171
@ConditionalOnProperty(prefix = "spring.shell.noninteractive", value = "enabled", havingValue = "true",
72-
matchIfMissing = true)
72+
matchIfMissing = false)
7373
public NonInteractiveShellRunner nonInteractiveApplicationRunner(Shell shell, ShellContext shellContext,
7474
ObjectProvider<NonInteractiveShellRunnerCustomizer> customizer) {
7575
NonInteractiveShellRunner shellRunner = new NonInteractiveShellRunner(shell, shellContext);

spring-shell-autoconfigure/src/test/java/org/springframework/shell/boot/ShellRunnerAutoConfigurationTests.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class ShellRunnerAutoConfigurationTests {
5656
class Interactive {
5757

5858
@Test
59-
void disabledByDefault() {
60-
contextRunner.run(context -> assertThat(context).doesNotHaveBean(InteractiveShellRunner.class));
59+
void enabledByDefault() {
60+
contextRunner.run(context -> assertThat(context).hasSingleBean(InteractiveShellRunner.class));
6161
}
6262

6363
@Test
@@ -71,21 +71,21 @@ void disabledWhenPropertySet() {
7171
@Nested
7272
class NonInteractive {
7373

74-
@Test
75-
void enabledByDefault() {
76-
contextRunner.run(context -> assertThat(context).hasSingleBean(NonInteractiveShellRunner.class));
77-
}
78-
7974
@Test
8075
void primaryCommandNotSet() {
81-
contextRunner.run(context -> {
76+
contextRunner.withPropertyValues("spring.shell.noninteractive.enabled:true").run(context -> {
8277
assertThat(context).hasSingleBean(NonInteractiveShellRunner.class);
8378
NonInteractiveShellRunner runner = context.getBean(NonInteractiveShellRunner.class);
8479
String command = (String) ReflectionTestUtils.getField(runner, "primaryCommand");
8580
assertThat(command).isNull();
8681
});
8782
}
8883

84+
@Test
85+
void disabledByDefault() {
86+
contextRunner.run(context -> assertThat(context).doesNotHaveBean(NonInteractiveShellRunner.class));
87+
}
88+
8989
@Test
9090
void disabledWhenPropertySet() {
9191
contextRunner.withPropertyValues("spring.shell.noninteractive.enabled:false")
@@ -95,10 +95,12 @@ void disabledWhenPropertySet() {
9595
@Test
9696
void canBeCustomized() {
9797
NonInteractiveShellRunnerCustomizer customizer = mock(NonInteractiveShellRunnerCustomizer.class);
98-
contextRunner.withBean(NonInteractiveShellRunnerCustomizer.class, () -> customizer).run(context -> {
99-
NonInteractiveShellRunner runner = context.getBean(NonInteractiveShellRunner.class);
100-
verify(customizer).customize(runner);
101-
});
98+
contextRunner.withPropertyValues("spring.shell.noninteractive.enabled:true")
99+
.withBean(NonInteractiveShellRunnerCustomizer.class, () -> customizer)
100+
.run(context -> {
101+
NonInteractiveShellRunner runner = context.getBean(NonInteractiveShellRunner.class);
102+
verify(customizer).customize(runner);
103+
});
102104
}
103105

104106
}

0 commit comments

Comments
 (0)