Implement ParameterDescription for the LegacyParameterResolver

Fixes #8

updated Help to support parameters with empty keys (e.g. default key in Shell 1)
updated LegacyParameterResolver to avoid including a default value if none is provided

included some additional sample commands
This commit is contained in:
camilojc
2017-05-19 23:58:06 +01:00
committed by Eric Bottard
parent 3b9bbff2f2
commit 72f52c65d8
6 changed files with 203 additions and 13 deletions

View File

@@ -107,12 +107,14 @@ public class Help {
if (description.defaultValue().isPresent()) {
result.append("[");
}
if (!description.mandatoryKey()) {
result.append("[");
}
result.append(description.keys().iterator().next(), AttributedStyle.BOLD);
if (!description.mandatoryKey()) {
result.append("]");
if(!description.keys().isEmpty()) {
if (!description.mandatoryKey()) {
result.append("[");
}
result.append(description.keys().iterator().next(), AttributedStyle.BOLD);
if (!description.mandatoryKey()) {
result.append("]");
}
if (!description.formal().isEmpty()) {
result.append(" ");
}
@@ -132,7 +134,9 @@ public class Help {
for (ParameterDescription description : parameterDescriptions) {
result.append("\t").append(description.keys().stream().collect(Collectors.joining(" or ")), AttributedStyle.BOLD);
if (description.formal().length() > 0) {
result.append(" ");
if (!description.keys().isEmpty()) {
result.append(" ");
}
appendUnderlinedFormal(result, description);
result.append("\n\t");
}

View File

@@ -100,7 +100,7 @@ public class StandardParameterResolver implements ParameterResolver {
@Override
public boolean supports(MethodParameter parameter) {
return true;
return parameter.getMethodAnnotation(ShellMethod.class) != null;
}
@Override