Skip to content

Commit 73bb79a

Browse files
springai/rag: show usage when add/search are typed without args
Reviewer noted that bare `ask` falls through to printing usage but bare `add` or `search` did not — the startsWith check required a trailing space. Apply the same equals|startsWith pattern that the ask branch already uses, with a length guard around the substring. Addresses brianstrauch review comment on PR #775. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3a4e2ab commit 73bb79a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

springai/rag/src/main/java/io/temporal/samples/springai/rag/RagApplication.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public void run(String... args) throws Exception {
9292
continue;
9393
}
9494

95-
if (input.startsWith("add ")) {
96-
String rest = input.substring(4).trim();
95+
if (input.equals("add") || input.startsWith("add ")) {
96+
String rest = input.length() > 3 ? input.substring(4).trim() : "";
9797
int spaceIndex = rest.indexOf(' ');
9898
if (spaceIndex == -1) {
9999
System.out.println("Usage: add <id> <content>");
@@ -121,8 +121,8 @@ public void run(String... args) throws Exception {
121121
continue;
122122
}
123123

124-
if (input.startsWith("search ")) {
125-
String query = input.substring(7).trim();
124+
if (input.equals("search") || input.startsWith("search ")) {
125+
String query = input.length() > 6 ? input.substring(7).trim() : "";
126126
if (query.isEmpty()) {
127127
System.out.println("Usage: search <query>");
128128
continue;

0 commit comments

Comments
 (0)