From 49750f5fb56b94ce0ee7a86b833aa7abf6db66ae Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 18 Oct 2024 22:30:10 +0300 Subject: can edit files when they are too large --- internal/prompt/prompt.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'internal/prompt') diff --git a/internal/prompt/prompt.go b/internal/prompt/prompt.go index e9d35c1..bf5997d 100644 --- a/internal/prompt/prompt.go +++ b/internal/prompt/prompt.go @@ -12,24 +12,34 @@ import ( ) var ( - ErrAborted = errors.New("aborted") - // TODO: Add edit functionality. 1. configure EDITOR, 2. fork EDITOR process on the given file. + ErrAborted = errors.New("aborted") ErrEditContent = errors.New("edit content") - contentColor = color.New(color.FgCyan, color.BgBlue, color.Bold).SprintFunc() - dangerColor = color.New(color.FgWhite, color.BgRed, color.Bold).SprintFunc() + blue = color.New(color.FgCyan, color.BgBlue, color.Bold).PrintfFunc() + red = color.New(color.FgWhite, color.BgRed, color.Bold).PrintfFunc() ) func DoYouWantThis(question, content string) error { - fmt.Print(contentColor(content)) + blue(content) fmt.Print("\n") return whatNow(question) } +func Acknowledge(message, content string) error { + blue(content) + fmt.Print("\n") + red(message + " (press enter)") + reader := bufio.NewReader(os.Stdin) + if _, err := reader.ReadString('\n'); err != nil { + return err + } + return nil +} + func whatNow(question string) error { reader := bufio.NewReader(os.Stdin) for { - fmt.Printf("%s ", dangerColor(fmt.Sprintf("%s (y=yes/n=no/e=edit):", question))) + red("%s (y=yes/n=no/e=edit):", question) input, err := reader.ReadString('\n') if err != nil { fmt.Println("Error reading input:", err) -- cgit v1.2.3