From 3f192bf2e304134b473135c66ff2c039f7a99c3d Mon Sep 17 00:00:00 2001 From: Clemens Fries Date: Mon, 12 Dec 2016 19:10:37 +0100 Subject: create: enable saving message under a different name --- cmd/create.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/create.go b/cmd/create.go index 3d02bc7..cba38b5 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -113,7 +113,7 @@ func Create(argv []string, conf *Configuration) { cmd.Run() if cmd.ProcessState.Success() { - fmt.Printf("\nSave message? ([(y)es], (d)raft, (n)o): ") + fmt.Printf("\nSave message? ([(y)es], (r)enamed, (d)raft, (n)o): ") reader := bufio.NewReader(os.Stdin) response, err := reader.ReadString('\n') @@ -133,6 +133,19 @@ func Create(argv []string, conf *Configuration) { dst = filepath.Join(todoDir, filepath.Base(tmpFile.Name())+".msg") dst, err = copyFile(tmpFile.Name(), dst, false) saved = true + case "r", "renamed": + fmt.Printf("\nSpecify new name: ") + reader := bufio.NewReader(os.Stdin) + response, err := reader.ReadString('\n') + + if err != nil { + fmt.Printf("Error when reading response: %s\n", err.Error()) + os.Exit(1) + } + + dst = filepath.Join(todoDir, strings.TrimSpace(response)+".msg") + dst, err = copyFile(tmpFile.Name(), dst, false) + saved = true case "d", "draft": dst = filepath.Join(draftsDir, filepath.Base(tmpFile.Name())+".msg") dst, err = copyFile(tmpFile.Name(), dst, false) -- cgit