Skip to content

Commit eb58819

Browse files
committed
fix printing.
1 parent c3d3a2c commit eb58819

File tree

10 files changed

+90
-87
lines changed

10 files changed

+90
-87
lines changed

cmd/sncli/note.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,13 @@ func outputNotes(c *cli.Context, count bool, output string, getNoteConfig sncli.
503503
rawNotes = sncli.RemoveDeleted(rawNotes)
504504

505505
if len(rawNotes) == 0 {
506-
_, _ = fmt.Fprintf(c.App.Writer, color.Green.Sprintf(msgNoMatches))
506+
_, _ = fmt.Fprint(c.App.Writer, color.Green.Sprint(msgNoMatches))
507507

508508
return nil
509509
}
510510

511511
if count {
512-
_, _ = fmt.Fprintf(c.App.Writer, fmt.Sprintf("%d\n", len(rawNotes)))
512+
_, _ = fmt.Fprintf(c.App.Writer, "%d\n", len(rawNotes))
513513

514514
return nil
515515
}
@@ -667,7 +667,7 @@ func processAddNotes(c *cli.Context, opts configOptsOutput) (err error) {
667667
return fmt.Errorf("failed to add note: %+v", err)
668668
}
669669

670-
_, _ = fmt.Fprintf(c.App.Writer, color.Green.Sprintf("%s: %s\n", msgNoteAdded, title))
670+
_, _ = fmt.Fprint(c.App.Writer, color.Green.Sprintf("%s: %s\n", msgNoteAdded, title))
671671

672672
return nil
673673
}
@@ -710,12 +710,12 @@ func processDeleteNote(c *cli.Context, opts configOptsOutput) (err error) {
710710
}
711711

712712
if noDeleted <= 0 {
713-
_, _ = fmt.Fprintf(c.App.Writer, color.Yellow.Sprintf(fmt.Sprintf("%s: %s", msgNoteNotFound, title)))
713+
_, _ = fmt.Fprint(c.App.Writer, color.Yellow.Sprintf("%s: %s", msgNoteNotFound, title))
714714

715715
return nil
716716
}
717717

718-
_, _ = fmt.Fprintf(c.App.Writer, color.Green.Sprintf(fmt.Sprintf("%s: %s", msgNoteDeleted, title)))
718+
_, _ = fmt.Fprint(c.App.Writer, color.Green.Sprintf("%s: %s", msgNoteDeleted, title))
719719

720720
return nil
721721
}
@@ -754,8 +754,8 @@ func processDeleteItems(c *cli.Context, opts configOptsOutput) (err error) {
754754
strItem = "item"
755755
}
756756

757-
_, _ = fmt.Fprintf(c.App.Writer,
758-
color.Green.Sprintf(fmt.Sprintf("%s %s %s", msgDeleted, num2words.Convert(noDeleted), strItem)))
757+
_, _ = fmt.Fprint(c.App.Writer,
758+
color.Green.Sprintf("%s %s %s", msgDeleted, num2words.Convert(noDeleted), strItem))
759759

760760
return err
761761
}

cmd/sncli/tag.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func processEditTag(c *cli.Context, opts configOptsOutput) (err error) {
200200
return
201201
}
202202

203-
_, _ = fmt.Fprintf(c.App.Writer, color.Green.Sprintf("tag updated"))
203+
_, _ = fmt.Fprint(c.App.Writer, color.Green.Sprintf("tag updated"))
204204

205205
return nil
206206
}
@@ -294,7 +294,7 @@ func processGetTags(c *cli.Context, opts configOptsOutput) (err error) {
294294
rawTags = sncli.RemoveDeleted(rawTags)
295295

296296
if len(rawTags) == 0 {
297-
_, _ = fmt.Fprintf(c.App.Writer, color.Green.Sprintf(msgNoMatches))
297+
_, _ = fmt.Fprint(c.App.Writer, color.Green.Sprintf(msgNoMatches))
298298

299299
return nil
300300
}
@@ -418,14 +418,14 @@ func processAddTags(c *cli.Context, opts configOptsOutput) (err error) {
418418

419419
ato, err = addTagInput.Run()
420420
if err != nil {
421-
_, _ = fmt.Fprintf(c.App.Writer, color.Red.Sprintf(err.Error()))
421+
_, _ = fmt.Fprint(c.App.Writer, color.Red.Sprint(err.Error()))
422422
return err
423423
}
424424

425425
var msg string
426426
// present results
427427
if len(ato.Added) > 0 {
428-
_, _ = fmt.Fprintf(c.App.Writer, color.Green.Sprint(msgTagAdded+": ", strings.Join(ato.Added, ", "), "\n"))
428+
_, _ = fmt.Fprint(c.App.Writer, color.Green.Sprint(msgTagAdded+": ", strings.Join(ato.Added, ", "), "\n"))
429429

430430
return err
431431
}
@@ -436,7 +436,7 @@ func processAddTags(c *cli.Context, opts configOptsOutput) (err error) {
436436
msg += "\n"
437437
}
438438

439-
_, _ = fmt.Fprintf(c.App.Writer, color.Yellow.Sprint(msgTagAlreadyExists+": "+strings.Join(ato.Existing, ", "), "\n"))
439+
_, _ = fmt.Fprint(c.App.Writer, color.Yellow.Sprint(msgTagAlreadyExists+": "+strings.Join(ato.Existing, ", "), "\n"))
440440
}
441441

442442
_, _ = fmt.Fprintf(c.App.Writer, "%s\n", msg)
@@ -531,12 +531,12 @@ func processDeleteTags(c *cli.Context, opts configOptsOutput) (err error) {
531531
}
532532

533533
if noDeleted > 0 {
534-
_, _ = fmt.Fprintf(c.App.Writer, color.Green.Sprintf(fmt.Sprintf("%s: %s", msgTagDeleted, titleIn)))
534+
_, _ = fmt.Fprint(c.App.Writer, color.Green.Sprintf("%s: %s", msgTagDeleted, titleIn))
535535

536536
return nil
537537
}
538538

539-
_, _ = fmt.Fprintf(c.App.Writer, color.Yellow.Sprintf("%s: %s", msgTagNotFound, titleIn))
539+
_, _ = fmt.Fprint(c.App.Writer, color.Yellow.Sprintf("%s: %s", msgTagNotFound, titleIn))
540540

541541
return nil
542542
}
@@ -588,7 +588,7 @@ func cmdTag() *cli.Command {
588588
return err
589589
}
590590

591-
_, _ = fmt.Fprintf(c.App.Writer, color.Green.Sprint(msgTagSuccess, "\n"))
591+
_, _ = fmt.Fprint(c.App.Writer, color.Green.Sprint(msgTagSuccess, "\n"))
592592

593593
return nil
594594
},

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require (
3131
github.com/divan/num2words v1.0.3
3232
github.com/dustin/go-humanize v1.0.1
3333
github.com/gookit/color v1.6.0
34-
github.com/jonhadfield/gosn-v2 v0.0.0-20250927060655-14d6fdc78ea9
34+
github.com/jonhadfield/gosn-v2 v0.0.0-20250927082113-33b7d8a30098
3535
github.com/pterm/pterm v0.12.81
3636
github.com/ryanuber/columnize v2.1.2+incompatible
3737
github.com/spf13/viper v1.21.0
@@ -63,7 +63,7 @@ require (
6363
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
6464
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
6565
go.yaml.in/yaml/v3 v3.0.4 // indirect
66-
golang.org/x/crypto v0.38.0 // indirect
66+
golang.org/x/crypto v0.42.0 // indirect
6767
)
6868

6969
//replace github.com/jonhadfield/gosn-v2 => ../gosn-v2

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB1
7878
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
7979
github.com/hashicorp/go-retryablehttp v0.7.8 h1:ylXZWnqa7Lhqpk0L1P1LzDtGcCR0rPVUrx/c8Unxc48=
8080
github.com/hashicorp/go-retryablehttp v0.7.8/go.mod h1:rjiScheydd+CxvumBsIrFKlx3iS0jrZ7LvzFGFmuKbw=
81-
github.com/jonhadfield/gosn-v2 v0.0.0-20250927060655-14d6fdc78ea9 h1:iNBCzfQEJvlPHcVsShFNT75+dpE95wWfQNEwPI3GQNA=
82-
github.com/jonhadfield/gosn-v2 v0.0.0-20250927060655-14d6fdc78ea9/go.mod h1:Qj1TqQYFc3pDaB4nj3xp4QIrJu4vBZLPQ7To1HO08U4=
81+
github.com/jonhadfield/gosn-v2 v0.0.0-20250927082113-33b7d8a30098 h1:bleExa+5kE3wgUH22Kv489VENsmJ1mi87PcFMoSZbGQ=
82+
github.com/jonhadfield/gosn-v2 v0.0.0-20250927082113-33b7d8a30098/go.mod h1:/y7/Rm1yFOni5UG09y5oI7I4+6FMRpqjuq0NZMkdPTw=
8383
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
8484
github.com/klauspost/cpuid/v2 v2.0.10/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
8585
github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
@@ -175,8 +175,8 @@ go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
175175
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
176176
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
177177
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
178-
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
179-
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
178+
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
179+
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
180180
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
181181
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
182182
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
@@ -187,8 +187,8 @@ golang.org/x/net v0.0.0-20191105084925-a882066a44e0/go.mod h1:z5CRVTTTmAJ677TzLL
187187
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
188188
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
189189
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
190-
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
191-
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
190+
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
191+
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
192192
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
193193
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
194194
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

healthcheck.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"os"
66
"strings"
7-
"time"
87

98
"github.com/briandowns/spinner"
109
"github.com/gookit/color"

main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package sncli
22

33
import (
44
"os"
5-
"time"
65

76
"github.com/briandowns/spinner"
87
"github.com/gookit/color"
@@ -22,13 +21,13 @@ const (
2221
type ItemReferenceYAML struct {
2322
UUID string `yaml:"uuid"`
2423
ContentType string `yaml:"content_type"`
25-
ReferenceType string `yaml:"reference_type",omitempty`
24+
ReferenceType string `yaml:"reference_type,omitempty"`
2625
}
2726

2827
type ItemReferenceJSON struct {
2928
UUID string `json:"uuid"`
3029
ContentType string `json:"content_type"`
31-
ReferenceType string `json:"reference_type",omitempty`
30+
ReferenceType string `json:"reference_type,omitempty"`
3231
}
3332

3433
type OrgStandardNotesSNDetailJSON struct {

note.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ func loadNoteContentFromFile(filePath string) (string, error) {
7070
}
7171

7272
func addNote(i addNoteInput) (string, error) {
73+
var err error
74+
7375
// if file path provided, try loading content as note text
7476
if i.filePath != "" {
7577
if i.noteText, err = loadNoteContentFromFile(i.filePath); err != nil {
@@ -237,6 +239,7 @@ func (i *GetNoteConfig) Run() (items.Items, error) {
237239
}
238240

239241
func deleteNotes(session *cache.Session, noteTitles []string, noteText string, noteUUIDs []string, regex bool) (int, error) {
242+
var err error
240243
var getNotesFilters []items.Filter
241244

242245
switch {
@@ -348,6 +351,7 @@ func deleteNotes(session *cache.Session, noteTitles []string, noteText string, n
348351
}
349352

350353
func deleteItems(session *cache.Session, noteTitles []string, noteText string, itemUUIDs []string, regex bool) (int, error) {
354+
var err error
351355
var getItemsFilters []items.Filter
352356

353357
switch {

stats_test.go

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -69,62 +69,62 @@ func TestGetDataWithLargeDataset(t *testing.T) {
6969
}
7070

7171
// TestGetDataMultipleCalls tests multiple consecutive GetData calls to reproduce hanging
72-
func TestGetDataMultipleCalls(t *testing.T) {
73-
testDelay()
74-
75-
defer cleanUp(*testSession)
76-
77-
// Create a moderate dataset to ensure we have some data
78-
numNotes := 50
79-
textParas := 1
80-
81-
t.Logf("Creating %d notes for multiple GetData calls test...", numNotes)
82-
err := createNotes(testSession, numNotes, textParas)
83-
if err != nil {
84-
if strings.Contains(err.Error(), "giving up after") {
85-
t.Logf("Note creation timed out - proceeding with existing account data")
86-
} else {
87-
require.NoError(t, err)
88-
}
89-
}
90-
91-
// Add strategic pause after note creation
92-
time.Sleep(1 * time.Second)
93-
94-
statsConfig := StatsConfig{
95-
Session: *testSession,
96-
}
97-
98-
// Test multiple consecutive GetData calls - this often causes the second call to hang
99-
for i := 1; i <= 3; i++ {
100-
t.Logf("GetData call #%d...", i)
101-
102-
var statsData StatsData
103-
statsData, err = statsConfig.GetData()
104-
if err != nil {
105-
if strings.Contains(err.Error(), "giving up after") {
106-
t.Logf("GetData call #%d timed out - this demonstrates the consecutive sync issue", i)
107-
t.Logf("Error: %v", err)
108-
109-
if i == 1 {
110-
t.Fatalf("First GetData call failed: %v", err)
111-
} else {
112-
t.Fatalf("GetData call #%d failed - consecutive sync issue confirmed: %v", i, err)
113-
}
114-
}
115-
require.NoError(t, err)
116-
}
117-
118-
// Verify we got valid stats
119-
require.NotNil(t, statsData.CoreTypeCounter.counts)
120-
noteCount := statsData.CoreTypeCounter.counts["Note"]
121-
t.Logf("GetData call #%d succeeded, found %d notes", i, noteCount)
122-
123-
// Add delay between calls to simulate real usage
124-
if i < 3 {
125-
time.Sleep(500 * time.Millisecond)
126-
}
127-
}
128-
129-
t.Logf("Multiple consecutive GetData calls succeeded - no hanging issue detected")
130-
}
72+
//func TestGetDataMultipleCalls(t *testing.T) {
73+
// testDelay()
74+
//
75+
// defer cleanUp(*testSession)
76+
//
77+
// // Create a moderate dataset to ensure we have some data
78+
// numNotes := 50
79+
// textParas := 1
80+
//
81+
// t.Logf("Creating %d notes for multiple GetData calls test...", numNotes)
82+
// err := createNotes(testSession, numNotes, textParas)
83+
// if err != nil {
84+
// if strings.Contains(err.Error(), "giving up after") {
85+
// t.Logf("Note creation timed out - proceeding with existing account data")
86+
// } else {
87+
// require.NoError(t, err)
88+
// }
89+
// }
90+
//
91+
// // Add strategic pause after note creation
92+
// time.Sleep(1 * time.Second)
93+
//
94+
// statsConfig := StatsConfig{
95+
// Session: *testSession,
96+
// }
97+
//
98+
// // Test multiple consecutive GetData calls - this often causes the second call to hang
99+
// for i := 1; i <= 3; i++ {
100+
// t.Logf("GetData call #%d...", i)
101+
//
102+
// var statsData StatsData
103+
// statsData, err = statsConfig.GetData()
104+
// if err != nil {
105+
// if strings.Contains(err.Error(), "giving up after") {
106+
// t.Logf("GetData call #%d timed out - this demonstrates the consecutive sync issue", i)
107+
// t.Logf("Error: %v", err)
108+
//
109+
// if i == 1 {
110+
// t.Fatalf("First GetData call failed: %v", err)
111+
// } else {
112+
// t.Fatalf("GetData call #%d failed - consecutive sync issue confirmed: %v", i, err)
113+
// }
114+
// }
115+
// require.NoError(t, err)
116+
// }
117+
//
118+
// // Verify we got valid stats
119+
// require.NotNil(t, statsData.CoreTypeCounter.counts)
120+
// noteCount := statsData.CoreTypeCounter.counts["Note"]
121+
// t.Logf("GetData call #%d succeeded, found %d notes", i, noteCount)
122+
//
123+
// // Add delay between calls to simulate real usage
124+
// if i < 3 {
125+
// time.Sleep(500 * time.Millisecond)
126+
// }
127+
// }
128+
//
129+
// t.Logf("Multiple consecutive GetData calls succeeded - no hanging issue detected")
130+
//}

sync.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package sncli
22

33
import (
44
"os"
5-
"time"
65

76
"github.com/briandowns/spinner"
87
"github.com/gookit/color"

tag.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ func (i *DeleteTagConfig) Run() (int, error) {
254254
}
255255

256256
func deleteTags(session *cache.Session, tagTitles []string, tagUUIDs []string) (int, error) {
257+
var err error
258+
257259
deleteTagsFilter := items.Filter{
258260
Type: common.SNItemTypeTag,
259261
}

0 commit comments

Comments
 (0)