diff --git a/cmd/attachments/main.go b/cmd/attachments/main.go new file mode 100644 index 0000000..a15158d --- /dev/null +++ b/cmd/attachments/main.go @@ -0,0 +1,49 @@ +package main + +import ( + "flag" + + "go.uber.org/zap" + + "code.ndumas.com/ndumas/obsidian-pipeline" +) + +func main() { + am := NewAttachmentMover() + defer am.L.Sync() + + flag.StringVar(&am.Source, "source", "", "source directory containing your vault") + flag.StringVar(&am.Target, "target", "", "target directory containing your hugo site") + flag.StringVar(&am.AttachmentsDir, "attachments", "", "directory containing your vault's attachments") + flag.StringVar(&am.BlogDir, "blog", "", "vault directory containing blog posts to-be-published") + + flag.Parse() + + switch { + case am.Source == "": + am.L.Fatal("please provide -source") + fallthrough + case am.Target == "": + am.L.Fatal("please provide -target") + fallthrough + case am.AttachmentsDir == "": + am.L.Fatal("please provide -attachments") + fallthrough + case am.BlogDir == "": + am.L.Fatal("please provide -blog") + } + + if am.Source == "" || am.Target == "" { + am.L.Fatal("flags not provided") + } + + err := am.Walk() + if err != nil { + am.L.Fatal("error walking blog or notes dir to gather file names", zap.Error(err)) + } + + err = am.Move() + if err != nil { + am.L.Fatal("error moving notes", zap.Error(err)) + } +} diff --git a/main.go b/main.go index b20beff..e69de29 100644 --- a/main.go +++ b/main.go @@ -1,47 +0,0 @@ -package main - -import ( - "flag" - - "go.uber.org/zap" -) - -func main() { - am := NewAttachmentMover() - defer am.L.Sync() - - flag.StringVar(&am.Source, "source", "", "source directory containing your vault") - flag.StringVar(&am.Target, "target", "", "target directory containing your hugo site") - flag.StringVar(&am.AttachmentsDir, "attachments", "", "directory containing your vault's attachments") - flag.StringVar(&am.BlogDir, "blog", "", "vault directory containing blog posts to-be-published") - - flag.Parse() - - switch { - case am.Source == "": - am.L.Fatal("please provide -source") - fallthrough - case am.Target == "": - am.L.Fatal("please provide -target") - fallthrough - case am.AttachmentsDir == "": - am.L.Fatal("please provide -attachments") - fallthrough - case am.BlogDir == "": - am.L.Fatal("please provide -blog") - } - - if am.Source == "" || am.Target == "" { - am.L.Fatal("flags not provided") - } - - err := am.Walk() - if err != nil { - am.L.Fatal("error walking blog or notes dir to gather file names", zap.Error(err)) - } - - err = am.Move() - if err != nil { - am.L.Fatal("error moving notes", zap.Error(err)) - } -}