aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorClemens Fries <github-lettersnail@xenoworld.de>2018-11-25 11:40:05 +0100
committerClemens Fries <github-lettersnail@xenoworld.de>2018-11-25 11:40:05 +0100
commit6a56223adcc731b6a50c9a8385191b94fb82dcd4 (patch)
tree86750fb8f34bc6e62d375c12b9dcbdb5abd3b62d /cmd
parenteac80b3843dbd94de2fc00e29c885dd90e261679 (diff)
create: rename: Do not allow empty file names
Diffstat (limited to 'cmd')
-rw-r--r--cmd/create.go7
1 files changed, 6 insertions, 1 deletions
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)