Rework help command
- Change help command output to get templated using model classes. - Remove things around ParameterDescription as those are replaced with template classes. - Fixes for native configs. - For now availability and aliases are removed from help to get back in better form. - Aliases has been partly introduced to structure. - Fixes #422
This commit is contained in:
committed by
GitHub
parent
eed1d84653
commit
bd9ab62013
@@ -188,6 +188,8 @@ public class SpringShellProperties {
|
||||
public static class HelpCommand {
|
||||
|
||||
private boolean enabled = true;
|
||||
private String commandTemplate = "classpath:template/help-command-default.stg";
|
||||
private String commandsTemplate = "classpath:template/help-commands-default.stg";
|
||||
private GroupingMode groupingMode = GroupingMode.GROUP;
|
||||
|
||||
public boolean isEnabled() {
|
||||
@@ -198,6 +200,22 @@ public class SpringShellProperties {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getCommandTemplate() {
|
||||
return commandTemplate;
|
||||
}
|
||||
|
||||
public void setCommandTemplate(String commandTemplate) {
|
||||
this.commandTemplate = commandTemplate;
|
||||
}
|
||||
|
||||
public String getCommandsTemplate() {
|
||||
return commandsTemplate;
|
||||
}
|
||||
|
||||
public void setCommandsTemplate(String commandsTemplate) {
|
||||
this.commandsTemplate = commandsTemplate;
|
||||
}
|
||||
|
||||
public GroupingMode getGroupingMode() {
|
||||
return groupingMode;
|
||||
}
|
||||
|
||||
@@ -55,11 +55,13 @@ public class StandardCommandsAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(Help.Command.class)
|
||||
@ConditionalOnProperty(prefix = "spring.shell.command.help", value = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
public Help help(SpringShellProperties properties) {
|
||||
Help help = new Help();
|
||||
public Help help(SpringShellProperties properties, ObjectProvider<TemplateExecutor> templateExecutor) {
|
||||
Help help = new Help(templateExecutor.getIfAvailable());
|
||||
if (properties.getCommand().getHelp().getGroupingMode() == GroupingMode.FLAT) {
|
||||
help.setShowGroups(false);
|
||||
}
|
||||
help.setCommandTemplate(properties.getCommand().getHelp().getCommandTemplate());
|
||||
help.setCommandsTemplate(properties.getCommand().getHelp().getCommandsTemplate());
|
||||
return help;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ public class SpringShellPropertiesTests {
|
||||
assertThat(properties.getCommand().getClear().isEnabled()).isTrue();
|
||||
assertThat(properties.getCommand().getHelp().isEnabled()).isTrue();
|
||||
assertThat(properties.getCommand().getHelp().getGroupingMode()).isEqualTo(GroupingMode.GROUP);
|
||||
assertThat(properties.getCommand().getHelp().getCommandTemplate()).isNotNull();
|
||||
assertThat(properties.getCommand().getHelp().getCommandsTemplate()).isNotNull();
|
||||
assertThat(properties.getCommand().getHistory().isEnabled()).isTrue();
|
||||
assertThat(properties.getCommand().getQuit().isEnabled()).isTrue();
|
||||
assertThat(properties.getCommand().getScript().isEnabled()).isTrue();
|
||||
@@ -78,6 +80,8 @@ public class SpringShellPropertiesTests {
|
||||
.withPropertyValues("spring.shell.command.clear.enabled=false")
|
||||
.withPropertyValues("spring.shell.command.help.enabled=false")
|
||||
.withPropertyValues("spring.shell.command.help.grouping-mode=flat")
|
||||
.withPropertyValues("spring.shell.command.help.command-template=fake1")
|
||||
.withPropertyValues("spring.shell.command.help.commands-template=fake2")
|
||||
.withPropertyValues("spring.shell.command.history.enabled=false")
|
||||
.withPropertyValues("spring.shell.command.quit.enabled=false")
|
||||
.withPropertyValues("spring.shell.command.script.enabled=false")
|
||||
@@ -109,6 +113,8 @@ public class SpringShellPropertiesTests {
|
||||
assertThat(properties.getCommand().getClear().isEnabled()).isFalse();
|
||||
assertThat(properties.getCommand().getHelp().isEnabled()).isFalse();
|
||||
assertThat(properties.getCommand().getHelp().getGroupingMode()).isEqualTo(GroupingMode.FLAT);
|
||||
assertThat(properties.getCommand().getHelp().getCommandTemplate()).isEqualTo("fake1");
|
||||
assertThat(properties.getCommand().getHelp().getCommandsTemplate()).isEqualTo("fake2");
|
||||
assertThat(properties.getCommand().getHistory().isEnabled()).isFalse();
|
||||
assertThat(properties.getCommand().getQuit().isEnabled()).isFalse();
|
||||
assertThat(properties.getCommand().getScript().isEnabled()).isFalse();
|
||||
|
||||
Reference in New Issue
Block a user