From aea7d45da42396922d4a09b95ef7a88888ede63e Mon Sep 17 00:00:00 2001 From: nthnn Date: Sun, 21 Jan 2024 14:02:18 +0800 Subject: [PATCH] Fixed 'description' attribute bugs. --- core/command.go | 4 ++-- util/io.go | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/command.go b/core/command.go index be55cbf..71733ec 100644 --- a/core/command.go +++ b/core/command.go @@ -122,13 +122,13 @@ func LogRepo() { qrepo, err := extractQrepoInfos() if err != nil { - fmt.Println("Error: " + err.Error()) + fmt.Println("\033[31mError\033[0m: " + err.Error()) return } fmt.Println("\033[35mName\033[0m:\t\t" + qrepo.Name) fmt.Println("\033[35mAuthor\033[0m:\t\t" + qrepo.Author) - fmt.Println("\033[35mDescription\033[0m:\t\t" + qrepo.Description) + fmt.Println("\033[35mDescription\033[0m:\t" + qrepo.Description) fmt.Println("\033[35mGit\033[0m:\t\t" + qrepo.Git) fmt.Println("\033[35mScripts\033[0m:\t" + strings.Join(qrepo.getMapKeys(), ", ")) } diff --git a/util/io.go b/util/io.go index 95ae32e..dd3f1b0 100644 --- a/util/io.go +++ b/util/io.go @@ -1,15 +1,21 @@ package util import ( + "bufio" "fmt" "os" ) func ReadString() string { - ln := "" - fmt.Scanf("%s", &ln) + scanner := bufio.NewScanner(os.Stdin) + scanner.Scan() - return ln + if err := scanner.Err(); err != nil { + fmt.Println("\033[31mError\033[0m: " + err.Error()) + os.Exit(0) + } + + return scanner.Text() } func WriteStringToFile(filename, content string) error {