Only NonInteractiveShellRunner is active on default

- Disable InteractiveShellRunner and ScriptShellRunner on default
- Enable those in commands and e2e sample apps
- Document changes
- Fixes #1017
This commit is contained in:
Janne Valkealahti
2024-03-10 13:48:54 +00:00
parent e46ded9289
commit cdbbf1d96d
5 changed files with 34 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 the original author or authors.
* Copyright 2021-2024 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.
@@ -59,7 +59,7 @@ public class ShellRunnerAutoConfiguration {
public static class NonePrimaryCommandConfiguration {
@Bean
@ConditionalOnProperty(prefix = "spring.shell.interactive", value = "enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(prefix = "spring.shell.interactive", value = "enabled", havingValue = "true", matchIfMissing = false)
public InteractiveShellRunner interactiveApplicationRunner(LineReader lineReader, PromptProvider promptProvider,
Shell shell, ShellContext shellContext) {
return new InteractiveShellRunner(lineReader, promptProvider, shell, shellContext);
@@ -75,7 +75,7 @@ public class ShellRunnerAutoConfiguration {
}
@Bean
@ConditionalOnProperty(prefix = "spring.shell.script", value = "enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(prefix = "spring.shell.script", value = "enabled", havingValue = "true", matchIfMissing = false)
public ScriptShellRunner scriptApplicationRunner(Parser parser, Shell shell) {
return new ScriptShellRunner(parser, shell);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 the original author or authors.
* Copyright 2022-2024 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.
@@ -53,9 +53,10 @@ class ShellRunnerAutoConfigurationTests {
@Nested
class Interactive {
@Test
void enabledByDefault() {
contextRunner.run(context -> assertThat(context).hasSingleBean(InteractiveShellRunner.class));
void disabledByDefault() {
contextRunner.run(context -> assertThat(context).doesNotHaveBean(InteractiveShellRunner.class));
}
@Test
@@ -67,6 +68,7 @@ class ShellRunnerAutoConfigurationTests {
@Nested
class NonInteractive {
@Test
void enabledByDefault() {
contextRunner.run(context -> assertThat(context).hasSingleBean(NonInteractiveShellRunner.class));
@@ -101,9 +103,10 @@ class ShellRunnerAutoConfigurationTests {
@Nested
class Script {
@Test
void enabledByDefault() {
contextRunner.run(context -> assertThat(context).hasSingleBean(ScriptShellRunner.class));
void disabledByDefault() {
contextRunner.run(context -> assertThat(context).doesNotHaveBean(ScriptShellRunner.class));
}
@Test