Pass ShellContext to CommandCatalog.of in CommandCatalogAutoConfiguration (#693)

- Fixes #702
This commit is contained in:
cachescrubber
2023-04-06 10:08:09 +02:00
committed by GitHub
parent a05752713d
commit 84cb5a7332
2 changed files with 5 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ import org.springframework.shell.command.CommandRegistration.BuilderSupplier;
import org.springframework.shell.command.CommandRegistration.OptionNameModifier;
import org.springframework.shell.command.support.OptionNameModifierSupport;
import org.springframework.shell.command.CommandResolver;
import org.springframework.shell.context.ShellContext;
@AutoConfiguration
@EnableConfigurationProperties(SpringShellProperties.class)
@@ -43,9 +44,10 @@ public class CommandCatalogAutoConfiguration {
@ConditionalOnMissingBean(CommandCatalog.class)
public CommandCatalog commandCatalog(ObjectProvider<MethodTargetRegistrar> methodTargetRegistrars,
ObjectProvider<CommandResolver> commandResolvers,
ObjectProvider<CommandCatalogCustomizer> commandCatalogCustomizers) {
ObjectProvider<CommandCatalogCustomizer> commandCatalogCustomizers,
ShellContext shellContext) {
List<CommandResolver> resolvers = commandResolvers.orderedStream().collect(Collectors.toList());
CommandCatalog catalog = CommandCatalog.of(resolvers, null);
CommandCatalog catalog = CommandCatalog.of(resolvers, shellContext);
methodTargetRegistrars.orderedStream().forEach(resolver -> {
resolver.register(catalog);
});

View File

@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class CommandCatalogAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class));
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class, ShellContextAutoConfiguration.class));
@Test
void defaultCommandCatalog() {