Skip to content

Commit c8d2b7e

Browse files
committed
Fix help command when a command is a prefix of another
1 parent bea8d3f commit c8d2b7e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/java/org/springframework/shell/core/SimpleParser.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.util.Set;
3131
import java.util.SortedSet;
3232
import java.util.TreeSet;
33-
import java.util.logging.Level;
3433
import java.util.logging.Logger;
3534

3635
import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
@@ -1045,7 +1044,13 @@ public void obtainHelp(
10451044
StringBuilder sb = new StringBuilder();
10461045

10471046
// Figure out if there's a single command we can offer help for
1048-
final Collection<MethodTarget> matchingTargets = locateTargets(buffer, false, false);
1047+
Collection<MethodTarget> matchingTargets = locateTargets(buffer, false, false);
1048+
for (MethodTarget candidate : matchingTargets) {
1049+
if (buffer.equals(candidate.getKey())) {
1050+
matchingTargets = Collections.singleton(candidate);
1051+
break;
1052+
}
1053+
}
10491054
if (matchingTargets.size() == 1) {
10501055
// Single command help
10511056
MethodTarget methodTarget = matchingTargets.iterator().next();
@@ -1115,8 +1120,6 @@ public void obtainHelp(
11151120
}
11161121

11171122
LOGGER.info(sb.toString());
1118-
// LOGGER.warning("** Type 'hint' (without the quotes) and hit ENTER for step-by-step guidance **"
1119-
// + StringUtils.LINE_SEPARATOR);
11201123
}
11211124
}
11221125

0 commit comments

Comments
 (0)