Fix output of multi-line notes (#89)

* Make output more condensed

* Fix broken output when adding notes with multiple lines

* 0.3.1
This commit is contained in:
Sung Won Cho 2018-07-07 23:46:14 +10:00 committed by GitHub
commit 021173e1d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View file

@ -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
}
}

View file

@ -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)"))

View file

@ -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
}