Closed
Description
Before we start to add anything related to new annotation model #637, it'd be good if we move legacy annotation commands and registration based commands in their own inner classes.
For example:
public class RequiredValueCommands {
private final static String REQUIRED_VALUE = "required-value";
private final static String ARG1_DESC = "Desc arg1";
private final static String ARG1_NAME = "arg1";
@ShellComponent
public static class RequiredValueCommandsLegacyAnnotation extends BaseE2ECommands {
@ShellMethod(key = LEGACY_ANNO + REQUIRED_VALUE, group = GROUP)
public String testRequiredValueLegacyAnnotation(
@ShellOption(help = ARG1_DESC)
String arg1
) {
return "Hello " + arg1;
}
}
@Component
public static class RequiredValueCommandsRegistration extends BaseE2ECommands {
@Bean
public CommandRegistration testRequiredValueRegistration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, REQUIRED_VALUE)
.group(GROUP)
.withOption()
.longNames(ARG1_NAME)
.description(ARG1_DESC)
.required()
.and()
.withTarget()
.function(ctx -> {
String arg1 = ctx.getOptionValue(ARG1_NAME);
return "Hello " + arg1;
})
.and()
.build();
}
}
}
This way when we start to add @Command
based commands we can have new inner class as well. Not doing this will cause a rebase hell with maintenance branches.