Skip to content

Commit fd5a395

Browse files
committed
fail if not not found.
1 parent fc99585 commit fd5a395

File tree

3 files changed

+46
-40
lines changed

3 files changed

+46
-40
lines changed

.golangci.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -145,26 +145,26 @@ linters-settings:
145145
# Check for plain error comparisons
146146
comparison: true
147147

148-
exhaustive:
149-
# check switch statements in generated files also
150-
check-generated: false
151-
# presence of "default" case in switch statements satisfies exhaustiveness,
152-
# even if all enum members are not listed
153-
default-signifies-exhaustive: false
154-
# enum members matching the supplied regex do not have to be listed in
155-
# switch statements to satisfy exhaustiveness
156-
ignore-enum-members: ""
157-
# consider enums only in package scopes, not in inner scopes
158-
package-scope-only: false
159-
160-
exhaustivestruct:
161-
# Struct Patterns is list of expressions to match struct packages and names
162-
# The struct packages have the form example.com/package.ExampleStruct
163-
# The matching patterns can use matching syntax from https://pkg.go.dev/path#Match
164-
# If this list is empty, all structs are tested.
165-
struct-patterns:
166-
- '*.Test'
167-
- 'example.com/package.ExampleStruct'
148+
# exhaustive:
149+
# # check switch statements in generated files also
150+
# check-generated: false
151+
# # presence of "default" case in switch statements satisfies exhaustiveness,
152+
# # even if all enum members are not listed
153+
# default-signifies-exhaustive: false
154+
# # enum members matching the supplied regex do not have to be listed in
155+
# # switch statements to satisfy exhaustiveness
156+
# ignore-enum-members: ""
157+
# # consider enums only in package scopes, not in inner scopes
158+
# package-scope-only: false
159+
#
160+
# exhaustivestruct:
161+
# # Struct Patterns is list of expressions to match struct packages and names
162+
# # The struct packages have the form example.com/package.ExampleStruct
163+
# # The matching patterns can use matching syntax from https://pkg.go.dev/path#Match
164+
# # If this list is empty, all structs are tested.
165+
# struct-patterns:
166+
# - '*.Test'
167+
# - 'example.com/package.ExampleStruct'
168168

169169
forbidigo:
170170
# Forbid the following identifiers (identifiers are written using regexp):

checklists.go

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ package sncli
22

33
import (
44
"fmt"
5+
"slices"
6+
"time"
7+
58
"github.com/alexeyco/simpletable"
69
"github.com/gookit/color"
710
"github.com/jonhadfield/gosn-v2/cache"
811
"github.com/jonhadfield/gosn-v2/items"
9-
"slices"
10-
"time"
1112
)
1213

13-
func conflictedWarning([]items.Checklist) string {
14-
if len(items.Checklists{}) > 0 {
15-
return color.Yellow.Sprintf("%d conflicted versions", len(items.Checklists{}))
14+
func conflictedWarning([]items.Tasklist) string {
15+
if len(items.Tasklists{}) > 0 {
16+
return color.Yellow.Sprintf("%d conflicted versions", len(items.Tasklists{}))
1617
}
1718

1819
return "-"
@@ -52,17 +53,17 @@ func (ci *ListChecklistsInput) Run() (err error) {
5253
return nil
5354
}
5455

55-
// construct a map of duplicates
56-
func getChecklistsDuplicatesMap(checklistNotes items.Notes) (map[string][]items.Checklist, error) {
57-
duplicates := make(map[string][]items.Checklist)
56+
// construct a map of duplicates.
57+
func getChecklistsDuplicatesMap(checklistNotes items.Notes) (map[string][]items.Tasklist, error) {
58+
duplicates := make(map[string][]items.Tasklist)
5859

5960
for x := range checklistNotes {
6061
if checklistNotes[x].DuplicateOf != "" {
6162
// checklist is a duplicate
6263
// get the checklist content
63-
cl, err := checklistNotes[x].Content.ToCheckList()
64+
cl, err := checklistNotes[x].Content.ToTaskList()
6465
if err != nil {
65-
return map[string][]items.Checklist{}, err
66+
return map[string][]items.Tasklist{}, err
6667
}
6768

6869
// skip trashed content
@@ -73,7 +74,7 @@ func getChecklistsDuplicatesMap(checklistNotes items.Notes) (map[string][]items.
7374
cl.UUID = checklistNotes[x].UUID
7475
cl.UpdatedAt, err = time.Parse(timeLayout, checklistNotes[x].UpdatedAt)
7576
if err != nil {
76-
return map[string][]items.Checklist{}, err
77+
return map[string][]items.Tasklist{}, err
7778
}
7879

7980
duplicates[checklistNotes[x].DuplicateOf] = append(duplicates[checklistNotes[x].DuplicateOf], cl)
@@ -83,28 +84,28 @@ func getChecklistsDuplicatesMap(checklistNotes items.Notes) (map[string][]items.
8384
return duplicates, nil
8485
}
8586

86-
func getChecklists(sess *cache.Session) (items.Checklists, error) {
87+
func getChecklists(sess *cache.Session) (items.Tasklists, error) {
8788
var so cache.SyncOutput
8889

8990
so, err := Sync(cache.SyncInput{
9091
Session: sess,
9192
}, true)
9293
if err != nil {
93-
return items.Checklists{}, err
94+
return items.Tasklists{}, err
9495
}
9596

9697
var allPersistedItems cache.Items
9798

9899
if err = so.DB.All(&allPersistedItems); err != nil {
99-
return items.Checklists{}, err
100+
return items.Tasklists{}, err
100101
}
101102

102103
allItemUUIDs := allPersistedItems.UUIDs()
103104

104105
var gitems items.Items
105106
gitems, err = allPersistedItems.ToItems(sess)
106107
if err != nil {
107-
return items.Checklists{}, err
108+
return items.Tasklists{}, err
108109
}
109110

110111
gitems.Filter(items.ItemFilters{
@@ -118,7 +119,7 @@ func getChecklists(sess *cache.Session) (items.Checklists, error) {
118119
},
119120
})
120121

121-
var checklists items.Checklists
122+
var checklists items.Tasklists
122123
checklistNotes := gitems.Notes()
123124

124125
duplicatesMap, err := getChecklistsDuplicatesMap(checklistNotes)
@@ -136,16 +137,16 @@ func getChecklists(sess *cache.Session) (items.Checklists, error) {
136137
continue
137138
}
138139

139-
var cl items.Checklist
140-
cl, err = checklistNotes[x].Content.ToCheckList()
140+
var cl items.Tasklist
141+
cl, err = checklistNotes[x].Content.ToTaskList()
141142
if err != nil {
142-
return items.Checklists{}, err
143+
return items.Tasklists{}, err
143144
}
144145

145146
cl.UUID = checklistNotes[x].UUID
146147
cl.UpdatedAt, err = time.Parse(timeLayout, checklistNotes[x].UpdatedAt)
147148
if err != nil {
148-
return items.Checklists{}, err
149+
return items.Tasklists{}, err
149150
}
150151

151152
cl.Duplicates = duplicatesMap[checklistNotes[x].UUID]

tag.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ func tagNotes(i tagNotesInput) (err error) {
108108
}
109109
}
110110

111+
if len(typeUUIDs[common.SNItemTypeNote]) == 0 {
112+
return errors.New("note not found")
113+
}
114+
111115
// update existing (and just created) tags to reference matching uuids
112116
// determine which TAGS need updating and create list to sync back to server
113117
var tagsToPush items.Tags
@@ -211,6 +215,7 @@ func (i *GetItemsConfig) Run() (items items.Items, err error) {
211215
}
212216

213217
items.FilterAllTypes(i.Filters)
218+
214219
return items, err
215220
}
216221

0 commit comments

Comments
 (0)