README.md (view raw)
1# `bibel` - Bible Verse CLI/TUI Utility
2
3A Go utility for displaying Bible verses with interactive terminal interface.
4This tool shows Bible verses based on the current date, displaying 12 verses
5per day through the four Gospels.
6
7## Features
8
9- **Interactive TUI**: Terminal User Interface using `bubbletea` with styled
10boxes
11- **Date-Based Progression**: Automatically calculates position based on day of
12year (1 January = Matthew 1:1-12)
13- **Smart Sizing**: Default snippet size is 12 verses, extends to end of
14chapter if less than 12 verses remain
15- **ANSI Colours: Uses ANSI terminal colours set by terminal emulator
16- **Interactive Controls**: Press `q` to quit (MOTD-like behaviour)
17- **Yearly Cycle**: Progresses through all four Gospels each year, restarting
18on 1 January
19- **Multiple Output Modes**: Interactive TUI, formatted ANSI, or plain text
20- **Verse Numbering**: Option to print each verse on a numbered line with verse
21numbers
22- **Paragraph Handling**: Option to render pilcrows (¶) in source JSON Bible
23file as paragraph breaks with blank lines
24- **Easter Progress Bar**: Fancy progress bar showing time until Easter with
25visual progress indication (default: Eastern Orthodox; Catholic with `-l` flag)
26
27## Installation
28
29```bash
30go build ./cmd/bibel.go
31```
32
33## Usage
34
35```bash
36./bibel
37```
38
39By default, the verses the program picks are done by:
401. Calculating today's date and day of year
412. Determining Bible position: day of year * 12 verses
423. Find corresponding verses in the Gospels
43
44### Usage Examples
45
46```bash
47# Default TUI mode with interactive display (shows Orthodox Easter progress)
48./bibel
49
50# Roman Catholic Easter progress bar instead of Orthodox
51./bibel --latin
52
53# Plain text output
54./bibel --plain
55
56# Formatted output with ANSI colours
57./bibel --formatted
58
59# Numbered verses (each verse on its own line with verse number)
60./bibel --numbered
61
62# Paragraph mode (pilcrows render as blank lines)
63./bibel --paragraphs
64
65# Combine numbered and paragraph modes
66./bibel --numbered --paragraphs
67
68# Plain output with numbered verses
69./bibel --plain --numbered
70
71# Generate configuration file
72./bibel --generate-config
73```
74
75This is default behaviour. Alternative configurations are available (see
76below).
77
78## Configuration
79
80`bibel` supports configuration via a TOML file located at
81`$XDG_CONFIG_HOME/bibel/config.toml` (default: `~/.config/bibel/config.toml`).
82Default macOS and Windows paths are also supported.
83
84### Configuration Options
85
86- **reading_mode**: Reading mode: "evangelion" (four Gospels; *default*),
87"new_testament", "old_testament", "bible" (default: "evangelion")
88- **output_mode**: Output mode: "tui" (interactive terminal UI), "formatted"
89(ANSI-coloured text), or "plain" (plain text)
90- **bible_path**: Path to Bible data file (default: "books/pol_nbg.json")
91
92#### TUI Settings (`[tui]` section)
93- **show_quit_message**: Whether to show "Press q to quit..." message (default:
94true)
95- **border_style**: Box border style: "rounded", "double", "single", or
96"hidden" (default: "rounded")
97
98#### Formatter Settings (`[formatter]` section)
99- **use_colours**: Whether to use ANSI colours in formatted output (default:
100true)
101- **header_format**: Header format template with variables: {book}, {chapter},
102{first_verse}, {second_verse}
103- **numbered**: Whether to print each verse on a numbered line corresponding to
104the verse number (default: false)
105- **paragraphs**: Whether to render pilcrows (¶) as blank lines instead of
106ignoring them (default: false)
107
108#### Date Progression Settings (`[date_progression]` section)
109- **verses_per_day**: Number of verses to read per day (default: 12)
110- **start_date**: Start date for yearly progression (format: "1 January", empty
111for current year)
112
113#### Easter Settings
114- **easter_type**: Easter calculation type: "orthodox" (default) or "latin"
115
116### Example Configuration
117
118See `configs/config.example.toml` in the project directory for a complete example.
119
120### Generating Configuration
121
122Generate a default configuration file:
123
124```bash
125./bibel --generate-config
126```
127
128### Command Line Arguments
129
130Command line arguments override configuration file settings:
131
132- `-r, --reading`: "evangelion" (four Gospels; *default*), "new_testament",
133"old_testament", "bible" (default: "evangelion")
134- `-p, --plain`: Output plain text without formatting or TUI
135- `-f, --formatted`: Output formatted text with ANSI colours (no TUI)
136- `-g, --generate-config`: Generate a default configuration file and exit
137- `-c, --config`: Path to configuration file (not yet implemented)
138- `-n, --numbered`: Print each verse on a numbered line corresponding to the verse number
139- `-g, --paragraphs`: Render pilcrows (¶) as blank lines instead of ignoring them
140- `-l, --latin`: Use Roman Catholic Easter instead of Eastern Orthodox (shows in TUI progress bar)
141
142## Data Format
143
144The Bible data is in JSON format (see `books/pol_nbg.json`) with the following
145structure:
146```json
147{
148 "metadata": { ... },
149 "verses": [
150 {
151 "book_name": "Mateusza",
152 "book": 40,
153 "chapter": 1,
154 "verse": 1,
155 "text": "¶ KSIĘGA początku Jezusa Chrystusa..."
156 },
157 ...
158 ]
159}
160```
161
162Books 40-43 correspond to the four Gospels:
163- 40: Matthew (Mateusza)
164- 41: Mark (Marek)
165- 42: Luke (Łukasz)
166- 43: John (Jana)
167
168## Date-Based Algorithm
169
170The program calculates reading position as follows:
171
1721. **Day of Year**: Get current day number (1-366)
1732. **Verse Offset**: Multiply by 12 verses per day: `offset = (day_of_year - 1)
174 × 12`
1753. **Modulo Wrap**: Apply modulo with total Gospel verses (3779) to cycle
176 yearly
1774. **Position Mapping**: Walk through Gospels to find corresponding verses
1785. **Lookahead Rule**: Extend to chapter end if less than 12 verses remain
179
180## Easter Progress Bar
181
182The TUI features a progress bar showing time until the next Easter:
183
184### Easter Type Selection
185- **Default**: Eastern Orthodox Easter (calculated via Meeus Julian algorithm)
186- **Catholic**: Roman Catholic Easter via `-l/--latin` flag (Delambre and Butcher's algorithm)
187
188### Progress Bar Features
189- **Visual Progress**: Filled segments (█) showing annual cycle percentage between consecutive Easters
190- **Time Display**: Shows exact days, hours, and minutes until next Easter
191- **Styling: Uses `lipgloss` with ANSI-coloured segments
192- **Configuration**: Easter type configurable via `easter_type` field in TOML configuration
193
194### Easter Calculations
195- **Orthodox Easter**: Uses Meeus Julian algorithm (accurate for years > 325)
196- **Catholic Easter**: Uses Delambre and Butcher's algorithm (Gregorian calendar)
197- **Annual Cycle Progress**: Calculated as time elapsed between consecutive Easters
198- **Real-time Updates**: Progress updates continuously while TUI is running
199
200## Project Structure
201
202```
203.
204├── cmd/bibel.go # Main CLI entry point
205├── configs/ # Default configuration files
206│ └── config.example.toml # The default configuration file
207├── internal/
208│ ├── config.go # Reading and writing to config
209│ ├── dateprogression.go # Date-based position calculation
210│ ├── easterprogression.go # Easter date and progress calculation
211│ ├── verse.go # Data structures
212│ ├── loader.go # JSON loading and indexing
213│ ├── formatter.go # Output formatting
214│ └── tui/ # Terminal User Interface
215│ └── model.go # bubbletea TUI model and styling
216├── pkg/
217│ └── eastertime.go # Easter date calculation algorithms (Orthodox/Catholic)
218├── books/pol_nbg.json # Bible data
219├── go.mod # Go module dependencies
220└── go.sum # Go dependency checksums
221```
222
223## Examples
224
225- **1 January**: Matthew 1:1-12
226- **2 January**: Matthew 1:13-25 (extends to end of chapter)
227- **16 April**: Mark 5:41-43
228- **31 December**: Matthew 18:7-18 (year wraps around)
229
230## Development
231
232```bash
233# Build
234go build ./cmd/bibel.go
235
236# Run
237./bibel
238```