Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = true

[*.{java,xml,gradle}]
indent_style = tab
indent_size = 4
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
*/
package org.springframework.shell.boot;

import org.springframework.shell.core.command.CommandRegistration;
import org.springframework.shell.core.command.Command;

/**
* Callback interface that can be used to customize a {@link CommandRegistration.Builder}.
* Callback interface that can be used to customize a {@link Command.Builder}.
*
* @author Janne Valkealahti
*/
@FunctionalInterface
public interface CommandRegistrationCustomizer {

/**
* Callback to customize a {@link CommandRegistration.Builder} instance.
* Callback to customize a {@link Command.Builder} instance.
* @param commandRegistrationBuilder the command registration builder to customize
*/
void customize(CommandRegistration.Builder commandRegistrationBuilder);
void customize(Command.Builder commandRegistrationBuilder);

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
import org.springframework.context.annotation.Bean;
import org.springframework.shell.core.MethodTargetRegistrar;
import org.springframework.shell.boot.SpringShellProperties.Help;
import org.springframework.shell.core.command.Command;
import org.springframework.shell.core.command.CommandRegistry;
import org.springframework.shell.core.command.CommandRegistryCustomizer;
import org.springframework.shell.core.command.CommandRegistration;
import org.springframework.shell.core.command.CommandRegistration.BuilderSupplier;
import org.springframework.shell.core.command.CommandRegistration.OptionNameModifier;
import org.springframework.shell.core.command.BuilderSupplier;
import org.springframework.shell.core.command.OptionNameModifier;
import org.springframework.shell.core.command.support.OptionNameModifierSupport;
import org.springframework.shell.core.command.CommandResolver;
import org.springframework.shell.core.context.ShellContext;
Expand All @@ -57,8 +57,7 @@ public CommandRegistry commandRegistry(ObjectProvider<MethodTargetRegistrar> met
}

@Bean
public CommandRegistryCustomizer defaultCommandRegistryCustomizer(
ObjectProvider<CommandRegistration> commandRegistrations) {
public CommandRegistryCustomizer defaultCommandRegistryCustomizer(ObjectProvider<Command> commandRegistrations) {
return registry -> {
commandRegistrations.orderedStream().forEach(registration -> {
registry.register(registration);
Expand All @@ -71,11 +70,10 @@ public CommandRegistrationCustomizer helpOptionsCommandRegistrationCustomizer(Sp
return registration -> {
Help help = properties.getHelp();
if (help.isEnabled()) {
registration.withHelpOptions()
.enabled(true)
registration.withHelpOptions(helpOptionsSpec -> helpOptionsSpec.enabled(true)
.longNames(help.getLongNames())
.shortNames(help.getShortNames())
.command(help.getCommand());
.command(help.getCommand()));
}
};
}
Expand Down Expand Up @@ -121,7 +119,7 @@ public CommandRegistrationCustomizer defaultOptionNameModifierCommandRegistratio
public BuilderSupplier commandRegistrationBuilderSupplier(
ObjectProvider<CommandRegistrationCustomizer> customizerProvider) {
return () -> {
CommandRegistration.Builder builder = CommandRegistration.builder();
Command.Builder builder = Command.builder();
customizerProvider.orderedStream().forEach((customizer) -> customizer.customize(builder));
return builder;
};
Expand Down
Loading