From 6a56223adcc731b6a50c9a8385191b94fb82dcd4 Mon Sep 17 00:00:00 2001 From: Clemens Fries Date: Sun, 25 Nov 2018 11:40:05 +0100 Subject: create: rename: Do not allow empty file names --- cmd/create.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/create.go b/cmd/create.go index 95bbdc9..3f24d12 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -113,6 +113,7 @@ func Create(argv []string, conf *Configuration) { cmd.Run() if cmd.ProcessState.Success() { + again: fmt.Printf("\nSave message? ([(y)es], (r)enamed, (d)raft, (n)o): ") reader := bufio.NewReader(os.Stdin) response, err := reader.ReadString('\n') @@ -134,10 +135,14 @@ func Create(argv []string, conf *Configuration) { dst, err = copyFile(tmpFile.Name(), dst, false) saved = true case "r", "renamed": - fmt.Printf("\nSpecify new name: ") + fmt.Printf("\nSpecify new name (leave empty to return to previous menu): ") reader := bufio.NewReader(os.Stdin) response, err := reader.ReadString('\n') + if strings.TrimSpace(response) == "" { + goto again + } + if err != nil { fmt.Printf("Error when reading response: %s\n", err.Error()) os.Exit(1) -- cgit