Skip to content

Commit 96b0541

Browse files
committed
implemented multi line or code block interactive query
1 parent e8361b9 commit 96b0541

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

internal/cli/interactive.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,27 @@ func StartInteractiveMode() {
3434

3535
for {
3636
fmt.Print("scmd> ")
37-
input, err := reader.ReadString('\n')
38-
if err != nil {
39-
fmt.Println("Error reading input:", err)
40-
continue
37+
38+
// Multi-line input: accumulate lines until the user submits
39+
// by pressing Enter on an empty line (blank line = submit).
40+
// This lets users paste or type multi-line queries freely.
41+
var lines []string
42+
for {
43+
line, err := reader.ReadString('\n')
44+
if err != nil {
45+
fmt.Println("Error reading input:", err)
46+
break
47+
}
48+
trimmed := strings.TrimSpace(line)
49+
if trimmed == "" {
50+
// Empty line: submit whatever we have accumulated
51+
break
52+
}
53+
lines = append(lines, trimmed)
54+
fmt.Print(" ... ")
4155
}
4256

57+
input := strings.Join(lines, " ")
4358
input = strings.TrimSpace(input)
4459
if input == "" {
4560
continue
@@ -142,6 +157,8 @@ func printWelcome() {
142157
fmt.Println(" Comma-separated = OR: docker,kubernetes,postgresql")
143158
fmt.Println(" Natural language: show me postgresql replication examples")
144159
fmt.Println()
160+
fmt.Println("Input: Type or paste your query, then press Enter on an empty line to submit.")
161+
fmt.Println()
145162
}
146163

147164
func processInteractiveCommand(input string) string {

0 commit comments

Comments
 (0)