feat(GODT-3121): KB suggestion test tool now support multi-line input.

This commit is contained in:
Xavier Michelon 2023-12-07 10:48:33 +01:00
parent 76087f1749
commit a057138880
1 changed files with 10 additions and 7 deletions

View File

@ -18,8 +18,8 @@
package main
import (
"bufio"
"fmt"
"io"
"os"
"github.com/ProtonMail/proton-bridge/v3/internal/kb"
@ -33,14 +33,17 @@ func checkErrors(err error) {
}
func main() {
var input string
fmt.Print("Type your input: ")
buffer := bufio.NewReader(os.Stdin)
input, err := buffer.ReadString('\n')
fi, err := os.Stdin.Stat()
checkErrors(err)
suggestions, err := kb.GetSuggestions(input)
if (fi.Mode() & os.ModeNamedPipe) == 0 {
fmt.Println("Type your input, Ctrl+D to finish: ")
}
bytes, err := io.ReadAll(os.Stdin)
checkErrors(err)
suggestions, err := kb.GetSuggestions(string(bytes))
checkErrors(err)
if len(suggestions) == 0 {