From 021173e1d9b5f2f07e62676809d0651028bc3da7 Mon Sep 17 00:00:00 2001 From: Sung Won Cho Date: Sat, 7 Jul 2018 23:46:14 +1000 Subject: [PATCH] Fix output of multi-line notes (#89) * Make output more condensed * Fix broken output when adding notes with multiple lines * 0.3.1 --- cmd/add/add.go | 5 ++++- cmd/cat/cat.go | 1 - core/core.go | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/add/add.go b/cmd/add/add.go index dc3c158f..f06f5a26 100644 --- a/cmd/add/add.go +++ b/cmd/add/add.go @@ -1,6 +1,7 @@ package add import ( + "fmt" "time" "github.com/dnote-io/cli/core" @@ -66,8 +67,10 @@ func newRun(ctx infra.DnoteCtx) core.RunEFunc { return errors.Wrap(err, "Failed to write note") } - log.Printf("note: \"%s\"\n", content) log.Successf("added to %s\n", bookName) + fmt.Printf("\n------------------------content------------------------\n") + fmt.Printf("%s", content) + fmt.Printf("\n-------------------------------------------------------\n") return nil } } diff --git a/cmd/cat/cat.go b/cmd/cat/cat.go index e2f48bee..0fd49e99 100644 --- a/cmd/cat/cat.go +++ b/cmd/cat/cat.go @@ -54,7 +54,6 @@ func newRun(ctx infra.DnoteCtx) core.RunEFunc { book := dnote[bookName] note := book.Notes[noteIdx] - log.Plain("\n") log.Infof("book name: %s\n", bookName) log.Infof("note uuid: %s\n", note.UUID) log.Infof("created at: %s\n", time.Unix(note.AddedOn, 0).Format("Jan 2, 2006 3:04pm (MST)")) diff --git a/core/core.go b/core/core.go index 443385af..ae8a0825 100644 --- a/core/core.go +++ b/core/core.go @@ -18,7 +18,7 @@ import ( const ( // Version is the current version of dnote - Version = "0.3.0" + Version = "0.3.1" // TimestampFilename is the name of the file containing upgrade info TimestampFilename = "timestamps" @@ -494,6 +494,11 @@ func SanitizeContent(s string) string { ret = strings.Trim(s, " ") + // Remove newline at the end of the file because POSIX defines a line as + // characters followed by a newline + ret = strings.TrimSuffix(ret, "\n") + ret = strings.TrimSuffix(ret, "\r\n") + return ret }