diff options
author | Clemens Fries <github-clockrotz@xenoworld.de> | 2016-12-12 19:10:37 +0100 |
---|---|---|
committer | Clemens Fries <github-clockrotz@xenoworld.de> | 2016-12-12 19:10:37 +0100 |
commit | 3f192bf2e304134b473135c66ff2c039f7a99c3d (patch) | |
tree | 995668a251b8a68174113b8ef4de918110346943 | |
parent | 533681e0f83ec4f69b3b8e9f1982ed9f089285b4 (diff) |
create: enable saving message under a different name
-rw-r--r-- | README.asciidoc | 8 | ||||
-rw-r--r-- | cmd/create.go | 15 |
2 files changed, 19 insertions, 4 deletions
diff --git a/README.asciidoc b/README.asciidoc index 8c344fa..9bf8bb8 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -376,13 +376,15 @@ After editing it will ask you if you want to add the message to the `todo` folder. ---- -Save message? ([(y)es], (d)raft, (n)o): +Save message? ([(y)es], (r)enamed, (d)raft, (n)o): ---- Answering `n` or `no` will discard the message, answering `d` or `draft` will add it to the `drafts` folder. If you type `y`, `yes`, or simply hit `ENTER` it -will be added to the `todo` folder. - +will be added to the `todo` folder. If you want to save the message under a +different name, but still into the `todo` folder, you may anwer with `r` or +`renamed` — the program will then prompt you for a new name, without the `.msg` +extension. === `check` command 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) |