Skip to content

Commit 5ff6c40

Browse files
cachescrubberjvalkeal
authored andcommitted
Pass ShellContext to CommandCatalog.of in CommandCatalogAutoConfiguration (#693)
- Backport #702 - Fixes #704
1 parent cd9651e commit 5ff6c40

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.springframework.shell.command.CommandRegistration.OptionNameModifier;
3535
import org.springframework.shell.command.support.OptionNameModifierSupport;
3636
import org.springframework.shell.command.CommandResolver;
37+
import org.springframework.shell.context.ShellContext;
3738

3839
@AutoConfiguration
3940
@EnableConfigurationProperties(SpringShellProperties.class)
@@ -43,9 +44,10 @@ public class CommandCatalogAutoConfiguration {
4344
@ConditionalOnMissingBean(CommandCatalog.class)
4445
public CommandCatalog commandCatalog(ObjectProvider<MethodTargetRegistrar> methodTargetRegistrars,
4546
ObjectProvider<CommandResolver> commandResolvers,
46-
ObjectProvider<CommandCatalogCustomizer> commandCatalogCustomizers) {
47+
ObjectProvider<CommandCatalogCustomizer> commandCatalogCustomizers,
48+
ShellContext shellContext) {
4749
List<CommandResolver> resolvers = commandResolvers.orderedStream().collect(Collectors.toList());
48-
CommandCatalog catalog = CommandCatalog.of(resolvers, null);
50+
CommandCatalog catalog = CommandCatalog.of(resolvers, shellContext);
4951
methodTargetRegistrars.orderedStream().forEach(resolver -> {
5052
resolver.register(catalog);
5153
});

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
public class CommandCatalogAutoConfigurationTests {
3737

3838
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
39-
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class));
39+
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class, ShellContextAutoConfiguration.class));
4040

4141
@Test
4242
void defaultCommandCatalog() {

0 commit comments

Comments
 (0)