mirror of
https://github.com/dnote/dnote
synced 2026-03-14 22:45:50 +01:00
parent
0a2413070f
commit
49754b58a4
4 changed files with 26 additions and 1 deletions
|
|
@ -50,7 +50,7 @@ Edit a note
|
|||
$ dnote edit linux 1
|
||||
|
||||
# Edit a note with the given index in the specified book with a content.
|
||||
$ dnote edit linux 1 "New Content"
|
||||
$ dnote edit linux 1 -c "New Content"
|
||||
```
|
||||
|
||||
## dnote remove
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ Run
|
|||
./scripts/test.sh
|
||||
```
|
||||
|
||||
## Debug
|
||||
|
||||
Run Dnote with `DNOTE_DEBUG=1` to print debugging statements.
|
||||
|
||||
## Release
|
||||
|
||||
This project uses [goreleaser](https://github.com/goreleaser/goreleaser) to automate the release process.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/dnote/actions"
|
||||
"github.com/dnote/cli/infra"
|
||||
"github.com/dnote/cli/log"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
@ -54,6 +55,8 @@ func handleAddNote(ctx infra.DnoteCtx, action actions.Action) error {
|
|||
return errors.Wrap(err, "Failed to parse the action data")
|
||||
}
|
||||
|
||||
log.Debug("reducing add_note. action: %+v. data: %+v\n", action, data)
|
||||
|
||||
note := infra.Note{
|
||||
UUID: data.NoteUUID,
|
||||
Content: data.Content,
|
||||
|
|
@ -99,6 +102,8 @@ func handleRemoveNote(ctx infra.DnoteCtx, action actions.Action) error {
|
|||
return errors.Wrap(err, "Failed to parse the action data")
|
||||
}
|
||||
|
||||
log.Debug("reducing remove_note. action: %+v. data: %+v\n", action, data)
|
||||
|
||||
dnote, err := GetDnote(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to get dnote")
|
||||
|
|
@ -128,6 +133,8 @@ func handleEditNoteV1(ctx infra.DnoteCtx, action actions.Action) error {
|
|||
return errors.Wrap(err, "Failed to parse the action data")
|
||||
}
|
||||
|
||||
log.Debug("reducing edit_note v1. action: %+v. data: %+v\n", action, data)
|
||||
|
||||
dnote, err := GetDnote(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to get dnote")
|
||||
|
|
@ -187,6 +194,8 @@ func handleEditNoteV2(ctx infra.DnoteCtx, action actions.Action) error {
|
|||
return errors.Wrap(err, "Failed to parse the action data")
|
||||
}
|
||||
|
||||
log.Debug("reducing edit_note v2. action: %+v. data: %+v\n", action, data)
|
||||
|
||||
dnote, err := GetDnote(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to get dnote")
|
||||
|
|
@ -269,6 +278,8 @@ func handleAddBook(ctx infra.DnoteCtx, action actions.Action) error {
|
|||
return errors.Wrap(err, "Failed to parse the action data")
|
||||
}
|
||||
|
||||
log.Debug("reducing add_book. action: %+v. data: %+v\n", action, data)
|
||||
|
||||
dnote, err := GetDnote(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to get dnote")
|
||||
|
|
@ -302,6 +313,8 @@ func handleRemoveBook(ctx infra.DnoteCtx, action actions.Action) error {
|
|||
return errors.Wrap(err, "Failed to parse the action data")
|
||||
}
|
||||
|
||||
log.Debug("reducing remove_book. action: %+v. data: %+v\n", action, data)
|
||||
|
||||
dnote, err := GetDnote(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to get dnote")
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package log
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
|
@ -55,3 +56,10 @@ func Errorf(msg string, v ...interface{}) {
|
|||
func Printf(msg string, v ...interface{}) {
|
||||
fmt.Fprintf(color.Output, "%s%s %s", indent, SprintfGray("•"), fmt.Sprintf(msg, v...))
|
||||
}
|
||||
|
||||
// Debug prints to the console if DNOTE_DEBUG is set
|
||||
func Debug(msg string, v ...interface{}) {
|
||||
if os.Getenv("DNOTE_DEBUG") == "1" {
|
||||
fmt.Fprintf(color.Output, "%s %s", SprintfGray("DEBUG:"), fmt.Sprintf(msg, v...))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue