Skip to content

Commit

Permalink
Pass ShellContext to CommandCatalog.of in CommandCatalogAutoConfigura…
Browse files Browse the repository at this point in the history
…tion (#693)

- Backport #702
- Fixes #703
  • Loading branch information
cachescrubber authored and jvalkeal committed Apr 6, 2023
1 parent 78faeac commit f3e3061
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.shell.command.CommandCatalogCustomizer;
import org.springframework.shell.command.CommandRegistration;
import org.springframework.shell.command.CommandResolver;
import org.springframework.shell.context.ShellContext;

@Configuration(proxyBeanMethods = false)
public class CommandCatalogAutoConfiguration {
Expand All @@ -35,9 +36,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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class CommandCatalogAutoConfigurationTests {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class));
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class, ShellContextAutoConfiguration.class));

@Test
void defaultCommandCatalog() {
Expand Down

0 comments on commit f3e3061

Please sign in to comment.