Skip to content

Commit

Permalink
fix(shell): help now matches full section titles
Browse files Browse the repository at this point in the history
  • Loading branch information
mchitre committed Nov 30, 2024
1 parent 4484ee0 commit 0029e21
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/org/arl/fjage/shell/Documentation.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Documentation {
protected int staticSize = 0;

protected static final Pattern heading = Pattern.compile("^#+ +([^ ]+) +-.*$");
protected static final Pattern section = Pattern.compile("^#+ .*$");
protected static final Pattern section = Pattern.compile("^#+ (.*)$");
protected static final String crlf = "\\r?\\n";
protected static final String header = "^#+ +";
protected static final String gaps = "\\n+$";
Expand Down Expand Up @@ -70,9 +70,16 @@ public String get(Agent agent, String keyword) {
for (int i = 0; i < doc.size(); i++) {
String s = doc.get(i);
Matcher m = heading.matcher(s);
if ((m.matches() && m.group(1).equals(keyword))) {
extract(sb, i);
count++;
continue;
}
m = section.matcher(s);
if (m.matches() && m.group(1).equals(keyword)) {
extract(sb, i);
count++;
continue;
}
}
if (count == 0) search(sb, keyword);
Expand Down

0 comments on commit 0029e21

Please sign in to comment.