Skip to content

Commit f3e3061

Browse files
cachescrubberjvalkeal
authored andcommitted
Pass ShellContext to CommandCatalog.of in CommandCatalogAutoConfiguration (#693)
- Backport #702 - Fixes #703
1 parent 78faeac commit f3e3061

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.shell.command.CommandCatalogCustomizer;
2828
import org.springframework.shell.command.CommandRegistration;
2929
import org.springframework.shell.command.CommandResolver;
30+
import org.springframework.shell.context.ShellContext;
3031

3132
@Configuration(proxyBeanMethods = false)
3233
public class CommandCatalogAutoConfiguration {
@@ -35,9 +36,10 @@ public class CommandCatalogAutoConfiguration {
3536
@ConditionalOnMissingBean(CommandCatalog.class)
3637
public CommandCatalog commandCatalog(ObjectProvider<MethodTargetRegistrar> methodTargetRegistrars,
3738
ObjectProvider<CommandResolver> commandResolvers,
38-
ObjectProvider<CommandCatalogCustomizer> commandCatalogCustomizers) {
39+
ObjectProvider<CommandCatalogCustomizer> commandCatalogCustomizers,
40+
ShellContext shellContext) {
3941
List<CommandResolver> resolvers = commandResolvers.orderedStream().collect(Collectors.toList());
40-
CommandCatalog catalog = CommandCatalog.of(resolvers, null);
42+
CommandCatalog catalog = CommandCatalog.of(resolvers, shellContext);
4143
methodTargetRegistrars.orderedStream().forEach(resolver -> {
4244
resolver.register(catalog);
4345
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
public class CommandCatalogAutoConfigurationTests {
3434

3535
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
36-
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class));
36+
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class, ShellContextAutoConfiguration.class));
3737

3838
@Test
3939
void defaultCommandCatalog() {

0 commit comments

Comments
 (0)