cmd/bibel.go (view raw)
1package main
2
3import (
4 "fmt"
5 "os"
6 "time"
7
8 "github.com/alexflint/go-arg"
9 "maxwelljensen/bibel/internal"
10)
11
12// Args defines the command line arguments
13type Args struct {
14 Plain bool `arg:"-p,--plain" help:"output plain text without chapter name or verse numbers"`
15}
16
17// Description returns a description of the program
18func (Args) Description() string {
19 return "Display today's Bible reading from the four Gospels (Matthew, Mark, Luke, John).\n" +
20 "Reads 12 verses per day based on the current date."
21}
22
23func main() {
24 var args Args
25 arg.MustParse(&args)
26
27 // Load Bible data
28 biblePath := "books/pol_nbg.json"
29 bibleData, err := bible.LoadBible(biblePath)
30 if err != nil {
31 fmt.Fprintf(os.Stderr, "Error loading Bible data: %v\n", err)
32 os.Exit(1)
33 }
34
35 // Initialise date progression
36 dateProg := bible.NewDateProgression(bibleData)
37
38 // Get current date
39 currentDate := time.Now()
40
41 // Calculate position for today
42 todayBookmark, err := dateProg.GetPositionForDate(currentDate)
43 if err != nil {
44 fmt.Fprintf(os.Stderr, "Error calculating date position: %v\n", err)
45 os.Exit(1)
46 }
47
48 // Initialise formatter
49 formatter := bible.NewFormatter()
50
51 // Print header (unless plain mode)
52 if !args.Plain {
53 fmt.Println(formatter.FormatHeader(todayBookmark))
54 }
55
56 // Print snippet
57 fmt.Println(formatter.ExtractAndFormat(bibleData, todayBookmark))
58}
59