From faf7569ab307eff706e4ccf2ed92eec5c93f67eb Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 22 Nov 2024 23:25:46 +0200 Subject: implement random other --- internal/prompt/file.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'internal/prompt/file.go') diff --git a/internal/prompt/file.go b/internal/prompt/file.go index 9668aed..2a23591 100644 --- a/internal/prompt/file.go +++ b/internal/prompt/file.go @@ -13,11 +13,11 @@ import ( ) var ( - ErrAborted = errors.New("aborted") - ErrDeleted = errors.New("deleted") + ErrAborted = errors.New("aborted") + ErrDeleted = errors.New("deleted") + ErrRamdomOther = errors.New("randomOther") ) -// TODO: Add option to randomly select another entry when no selected? func FileAction(question, content, filePath string) (string, error) { colour.Info2f(filePath + ":") fmt.Print("\n") @@ -26,7 +26,7 @@ func FileAction(question, content, filePath string) (string, error) { reader := bufio.NewReader(os.Stdin) for { - colour.Ackf("%s (y=yes/n=no/e=edit/d=delete):", question) + colour.Ackf("%s (y=yes/n=no/e=edit/d=delete/r=random other):", question) input, err := reader.ReadString('\n') if err != nil { fmt.Println("Error reading input:", err) @@ -51,6 +51,8 @@ func FileAction(question, content, filePath string) (string, error) { return content, err } return content, fmt.Errorf("%w %s", ErrDeleted, filePath) + case "r", "random", "random other": + return content, fmt.Errorf("%w %s", ErrRamdomOther, filePath) default: fmt.Println("Please enter 'y' or 'n' or 'e' or 'd'.") } -- cgit v1.2.3