cmd/bibel.go (view raw)
1package main
2
3import (
4 "fmt"
5 "os"
6
7 "maxwelljensen/bibel/internal"
8)
9
10func main() {
11 // TEST: Initialise components
12 biblePath := "books/pol_nbg.json"
13 bookmarkPath := "test/bookmark.toml"
14
15 // Load Bible data
16 bibleData, err := bible.LoadBible(biblePath)
17 if err != nil {
18 fmt.Fprintf(os.Stderr, "Error loading Bible data: %v\n", err)
19 os.Exit(1)
20 }
21
22 // Initialise bookmark manager
23 bookmarkMgr := bible.NewBookmarkManager(bookmarkPath)
24
25 // Read current bookmark
26 currentBookmark, err := bookmarkMgr.ReadBookmark()
27 if err != nil {
28 fmt.Fprintf(os.Stderr, "Error reading bookmark: %v\n", err)
29 os.Exit(1)
30 }
31
32 // Adjust bookmark based on lookahead rule
33 adjustedBookmark := bookmarkMgr.AdjustForLookahead(currentBookmark, bibleData)
34
35 // Initialise formatter
36 formatter := bible.NewFormatter()
37
38 // Print header and snippet
39 fmt.Println(formatter.FormatHeader(adjustedBookmark))
40 fmt.Println(formatter.ExtractAndFormat(bibleData, adjustedBookmark))
41
42 // Calculate next bookmark
43 nextBookmark := bookmarkMgr.AdvanceBookmark(adjustedBookmark, bibleData)
44
45 // Write next bookmark
46 if err := bookmarkMgr.WriteBookmark(nextBookmark); err != nil {
47 fmt.Fprintf(os.Stderr, "Error writing next bookmark: %v\n", err)
48 os.Exit(1)
49 }
50}
51