From 5123f6e1fd61ebd92b2585cb0c939dbce6d4e0be Mon Sep 17 00:00:00 2001 From: vudayani Date: Thu, 6 Jun 2024 11:52:04 +0530 Subject: [PATCH] add enhance-response command --- .../org/springframework/cli/command/AiCommands.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/springframework/cli/command/AiCommands.java b/src/main/java/org/springframework/cli/command/AiCommands.java index 35a1f0b7..755a252b 100644 --- a/src/main/java/org/springframework/cli/command/AiCommands.java +++ b/src/main/java/org/springframework/cli/command/AiCommands.java @@ -18,11 +18,13 @@ import java.util.Optional; +import com.fasterxml.jackson.core.JsonProcessingException; import org.jline.utils.AttributedStringBuilder; import org.jline.utils.AttributedStyle; import org.springframework.beans.BeansException; import org.springframework.cli.merger.ai.OpenAiHandler; +import org.springframework.cli.merger.ai.ResponseModifier; import org.springframework.cli.merger.ai.service.GenerateCodeAiService; import org.springframework.cli.util.TerminalMessage; import org.springframework.context.ApplicationContext; @@ -57,6 +59,16 @@ public void aiAdd(@Option( this.openAiHandler.add(description, path, preview, rewrite, terminalMessage); } + @Command(command = "enhance-response", + description = "Enhance the AI response for a Spring project, i.e. make response Boot 3 compliant if necessary etc.") + public String aiModifyResponse( + @Option(description = "README.md file path containing the response from the AI.") String file, + @Option(description = "Path on which to run the command. Most of the time, you can not specify the path and use the default value, which is the current working directory.") String path) + throws JsonProcessingException { + ResponseModifier responseModifier = new ResponseModifier(); + return responseModifier.modify(file, path); + } + private void printMissingDescriptionMessage() { AttributedStringBuilder sb = new AttributedStringBuilder(); sb.style(sb.style().foreground(AttributedStyle.WHITE));