(ctx context.DnoteCtx, rowIDArg string)
| 118 | } |
| 119 | |
| 120 | func runNote(ctx context.DnoteCtx, rowIDArg string) error { |
| 121 | db := ctx.DB |
| 122 | |
| 123 | noteRowID, err := strconv.Atoi(rowIDArg) |
| 124 | if err != nil { |
| 125 | return errors.Wrap(err, "invalid rowid") |
| 126 | } |
| 127 | |
| 128 | noteInfo, err := database.GetNoteInfo(db, noteRowID) |
| 129 | if err != nil { |
| 130 | return err |
| 131 | } |
| 132 | |
| 133 | output.NoteInfo(os.Stdout, noteInfo) |
| 134 | |
| 135 | ok, err := maybeConfirm("remove this note?", false) |
| 136 | if err != nil { |
| 137 | return errors.Wrap(err, "getting confirmation") |
| 138 | } |
| 139 | if !ok { |
| 140 | log.Warnf("aborted by user\n") |
| 141 | return nil |
| 142 | } |
| 143 | |
| 144 | tx, err := db.Begin() |
| 145 | if err != nil { |
| 146 | return errors.Wrap(err, "beginning a transaction") |
| 147 | } |
| 148 | |
| 149 | if _, err = tx.Exec("UPDATE notes SET deleted = ?, dirty = ?, body = ? WHERE uuid = ?", true, true, "", noteInfo.UUID); err != nil { |
| 150 | tx.Rollback() |
| 151 | return errors.Wrap(err, "removing the note") |
| 152 | } |
| 153 | |
| 154 | err = tx.Commit() |
| 155 | if err != nil { |
| 156 | tx.Rollback() |
| 157 | return errors.Wrap(err, "comitting transaction") |
| 158 | } |
| 159 | |
| 160 | log.Successf("removed from %s\n", noteInfo.BookLabel) |
| 161 | |
| 162 | return nil |
| 163 | } |
| 164 | |
| 165 | func runBook(ctx context.DnoteCtx, bookLabel string) error { |
| 166 | db := ctx.DB |
no test coverage detected