home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

commit ae4fbfc1a3b8350a7e120f2604ab308d08d6f10c
parent cf0243271b42e0fd571e31cd6641fee9a6b8df59
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Thu, 13 Jun 2024 12:04:40 +0200

tools/go-org-readwise: remove org dependency

It doesn't fullfill my need, so I'll handle this my way, and in a very
simple fashion.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Mtools/go-org-readwise/go.mod | 8--------
Mtools/go-org-readwise/internal/org/org.go | 17++++++++++++-----
Mtools/go-org-readwise/main.go | 5+++++
3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/tools/go-org-readwise/go.mod b/tools/go-org-readwise/go.mod @@ -1,11 +1,3 @@ module github.com/vdemeester/home/tools/go-org-readwise go 1.22 - -require github.com/niklasfasching/go-org v1.7.0 - -require ( - github.com/alecthomas/chroma/v2 v2.5.0 // indirect - github.com/dlclark/regexp2 v1.4.0 // indirect - golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect -) diff --git a/tools/go-org-readwise/internal/org/org.go b/tools/go-org-readwise/internal/org/org.go @@ -2,11 +2,12 @@ package org import ( "context" + "errors" "fmt" + "os" "regexp" "strings" - "github.com/niklasfasching/go-org/org" "github.com/vdemeester/home/tools/go-org-readwise/internal/readwise" ) @@ -41,6 +42,16 @@ func Sync(ctx context.Context, target string, results []readwise.Result) error { // use a regexp to "detect" part of the thing. filename := denoteFilename(result) fmt.Println("file", filename) + if _, err := os.Stat(filename); err == nil { + // Append to the file + return errors.New("Not implemented") + } else if errors.Is(err, os.ErrNotExist) { + // Create the file + } else { + // Schrodinger: file may or may not exist. See err for details. + // Therefore, do *NOT* use !os.IsNotExist(err) to test for file existence + return err + } } return nil } @@ -106,7 +117,3 @@ func sluggify(s string) string { s = strings.TrimSuffix(s, "-") return s } - -func Foo() { - org.New() -} diff --git a/tools/go-org-readwise/main.go b/tools/go-org-readwise/main.go @@ -14,6 +14,11 @@ import ( ) func main() { + // for _, n := range d.Nodes { + // fmt.Printf("%+v\n", n) + // } + + os.Exit(1) apiKeyFile := flag.String("apiKeyFile", "", "File to load the apiKey from. If empty, it will defer to the READWISE_KEY environment variable") targetFolder := flag.String("targetFolder", "", "Folder to write highlights (in org file) into") flag.Parse()