Skip to content

Commit 77fc68c

Browse files
committed
Introduce new command DSL
Signed-off-by: Piotr Olaszewski <[email protected]>
1 parent 7199ea4 commit 77fc68c

File tree

46 files changed

+1291
-1208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1291
-1208
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
*/
1616
package org.springframework.shell.boot;
1717

18-
import org.springframework.shell.core.command.CommandRegistration;
18+
import org.springframework.shell.core.command.Command;
1919

2020
/**
21-
* Callback interface that can be used to customize a {@link CommandRegistration.Builder}.
21+
* Callback interface that can be used to customize a {@link Command.Builder}.
2222
*
2323
* @author Janne Valkealahti
2424
*/
2525
@FunctionalInterface
2626
public interface CommandRegistrationCustomizer {
2727

2828
/**
29-
* Callback to customize a {@link CommandRegistration.Builder} instance.
29+
* Callback to customize a {@link Command.Builder} instance.
3030
* @param commandRegistrationBuilder the command registration builder to customize
3131
*/
32-
void customize(CommandRegistration.Builder commandRegistrationBuilder);
32+
void customize(Command.Builder commandRegistrationBuilder);
3333

3434
}

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
import org.springframework.context.annotation.Bean;
2828
import org.springframework.shell.core.MethodTargetRegistrar;
2929
import org.springframework.shell.boot.SpringShellProperties.Help;
30+
import org.springframework.shell.core.command.Command;
3031
import org.springframework.shell.core.command.CommandRegistry;
3132
import org.springframework.shell.core.command.CommandRegistryCustomizer;
32-
import org.springframework.shell.core.command.CommandRegistration;
33-
import org.springframework.shell.core.command.CommandRegistration.BuilderSupplier;
34-
import org.springframework.shell.core.command.CommandRegistration.OptionNameModifier;
33+
import org.springframework.shell.core.command.BuilderSupplier;
34+
import org.springframework.shell.core.command.OptionNameModifier;
3535
import org.springframework.shell.core.command.support.OptionNameModifierSupport;
3636
import org.springframework.shell.core.command.CommandResolver;
3737
import org.springframework.shell.core.context.ShellContext;
@@ -57,8 +57,7 @@ public CommandRegistry commandRegistry(ObjectProvider<MethodTargetRegistrar> met
5757
}
5858

5959
@Bean
60-
public CommandRegistryCustomizer defaultCommandRegistryCustomizer(
61-
ObjectProvider<CommandRegistration> commandRegistrations) {
60+
public CommandRegistryCustomizer defaultCommandRegistryCustomizer(ObjectProvider<Command> commandRegistrations) {
6261
return registry -> {
6362
commandRegistrations.orderedStream().forEach(registration -> {
6463
registry.register(registration);
@@ -71,11 +70,10 @@ public CommandRegistrationCustomizer helpOptionsCommandRegistrationCustomizer(Sp
7170
return registration -> {
7271
Help help = properties.getHelp();
7372
if (help.isEnabled()) {
74-
registration.withHelpOptions()
75-
.enabled(true)
73+
registration.withHelpOptions(helpOptionsSpec -> helpOptionsSpec.enabled(true)
7674
.longNames(help.getLongNames())
7775
.shortNames(help.getShortNames())
78-
.command(help.getCommand());
76+
.command(help.getCommand()));
7977
}
8078
};
8179
}
@@ -121,7 +119,7 @@ public CommandRegistrationCustomizer defaultOptionNameModifierCommandRegistratio
121119
public BuilderSupplier commandRegistrationBuilderSupplier(
122120
ObjectProvider<CommandRegistrationCustomizer> customizerProvider) {
123121
return () -> {
124-
CommandRegistration.Builder builder = CommandRegistration.builder();
122+
Command.Builder builder = Command.builder();
125123
customizerProvider.orderedStream().forEach((customizer) -> customizer.customize(builder));
126124
return builder;
127125
};

0 commit comments

Comments
 (0)