From 3d8935e6456bcfe462bd7735615e9009ef5ff7c6 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 27 Oct 2024 17:19:34 +0200 Subject: can ask before queueing --- internal/prompt/prompt.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'internal/prompt') diff --git a/internal/prompt/prompt.go b/internal/prompt/prompt.go index fb5b870..e9c5e72 100644 --- a/internal/prompt/prompt.go +++ b/internal/prompt/prompt.go @@ -14,10 +14,13 @@ import ( var ( ErrAborted = errors.New("aborted") ErrEditContent = errors.New("edit content") + ErrDeleteFile = errors.New("delete file") info = color.New(color.FgCyan, color.BgBlue, color.Bold).PrintfFunc() ack = color.New(color.FgHiBlack, color.BgHiGreen, color.Bold).PrintfFunc() ) +// TODO: Refactor this prompt, including all operations done on the file, like abort, edit, remove, etc. +// TODO: And also don't use error for control flow. func DoYouWantThis(question, content string) error { info(content) fmt.Print("\n") @@ -39,7 +42,7 @@ func whatNow(question string) error { reader := bufio.NewReader(os.Stdin) for { - ack("%s (y=yes/n=no/e=edit):", question) + ack("%s (y=yes/n=no/e=edit/d=delete):", question) input, err := reader.ReadString('\n') if err != nil { fmt.Println("Error reading input:", err) @@ -53,8 +56,11 @@ func whatNow(question string) error { return ErrAborted case "e", "edit": return ErrEditContent + case "d", "delete": + // TODO: Implement + return ErrDeleteFile default: - fmt.Println("Please enter 'y' or 'n' or 'e'.") + fmt.Println("Please enter 'y' or 'n' or 'e' or 'd'.") } } } -- cgit v1.2.3