Add commands as list in help templating
- Add getNames method. - Add docs for templating info and fields to help. - Fixes #480
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.shell.standard.commands;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -98,6 +99,10 @@ class CommandInfoModel {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<String> getNames() {
|
||||
return Arrays.asList(name.split(" "));
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,28 @@ public class CommandInfoModelTests {
|
||||
assertThat(cim.getName()).isEqualTo("main1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasGivenNames() {
|
||||
CommandRegistration r1 = CommandRegistration.builder()
|
||||
.command("main1")
|
||||
.withTarget()
|
||||
.consumer(ctx -> {})
|
||||
.and()
|
||||
.build();
|
||||
CommandInfoModel cim = CommandInfoModel.of("main1", r1);
|
||||
assertThat(cim.getNames()).containsExactly("main1");
|
||||
|
||||
r1 = CommandRegistration.builder()
|
||||
.command("main1 sub1")
|
||||
.withTarget()
|
||||
.consumer(ctx -> {})
|
||||
.and()
|
||||
.build();
|
||||
|
||||
cim = CommandInfoModel.of("main1 sub1", r1);
|
||||
assertThat(cim.getNames()).containsExactly("main1", "sub1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasGivenDescription() {
|
||||
CommandRegistration r1 = CommandRegistration.builder()
|
||||
|
||||
Reference in New Issue
Block a user