# `bibel` - Bible Verse CLI/TUI Utility A Go utility for displaying Bible verses with interactive terminal interface. This tool shows Bible verses based on the current date, displaying 12 verses per day through the four Gospels. ## Features - **Interactive TUI**: Terminal User Interface using `bubbletea` with styled boxes - **Date-Based Progression**: Automatically calculates position based on day of year (1 January = Matthew 1:1-12) - **Smart Sizing**: Default snippet size is 12 verses, extends to end of chapter if less than 12 verses remain - **Adaptive Styling**: Terminal-adaptive colours and borders using `lipgloss` - **Interactive Controls**: Press `q` to quit (MOTD-like behaviour) - **Yearly Cycle**: Progresses through all four Gospels each year, restarting on 1 January - **Multiple Output Modes**: Interactive TUI, formatted ANSI, or plain text ## Installation ```bash go build ./cmd/bibel.go ``` ## Usage ```bash ./bibel ``` By default, the verses the program picks are done by: 1. Calculating today's date and day of year 2. Determining Bible position: day of year * 12 verses 3. Find corresponding verses in the Gospels This is default behaviour. Alternative configurations are available (see below). ## Configuration `bibel` supports configuration via a TOML file located at `$XDG_CONFIG_HOME/bibel/config.toml` (default: `~/.config/bibel/config.toml`). Default macOS and Windows paths are also supported. ### Configuration Options - **reading_mode**: Reading mode: "evangelion" (four Gospels; *default*), "new_testament", "old_testament", "bible" (default: "evangelion") - **output_mode**: Output mode: "tui" (interactive terminal UI), "formatted" (ANSI-coloured text), or "plain" (plain text) - **bible_path**: Path to Bible data file (default: "books/pol_nbg.json") #### TUI Settings (`[tui]` section) - **show_quit_message**: Whether to show "Press q to quit..." message (default: true) - **border_style**: Box border style: "rounded", "double", "single", or "hidden" (default: "rounded") - **border_colour**: Box border colour (hex or named colour, empty for adaptive) - **header_colour**: Header text colour (empty for adaptive) - **text_colour**: Bible text colour (empty for adaptive) - **quit_colour**: Quit message colour (empty for adaptive) #### Formatter Settings (`[formatter]` section) - **use_colours**: Whether to use ANSI colours in formatted output (default: true) - **header_format**: Header format template with variables: {book}, {chapter}, {first_verse}, {second_verse} #### Date Progression Settings (`[date_progression]` section) - **verses_per_day**: Number of verses to read per day (default: 12) - **start_date**: Start date for yearly progression (format: "1 January", empty for current year) ### Example Configuration See `configs/config.example.toml` in the project directory for a complete example. ### Generating Configuration Generate a default configuration file: ```bash ./bibel --generate-config ``` ### Command Line Arguments Command line arguments override configuration file settings: - `-r, --reading`: "evangelion" (four Gospels; *default*), "new_testament", "old_testament", "bible" (default: "evangelion") - `-p, --plain`: Output plain text without formatting or TUI - `-f, --formatted`: Output formatted text with ANSI colours (no TUI) - `-g, --generate-config`: Generate a default configuration file and exit - `-c, --config`: Path to configuration file (not yet implemented) ## Data Format The Bible data is in JSON format (see `books/pol_nbg.json`) with the following structure: ```json { "metadata": { ... }, "verses": [ { "book_name": "Mateusza", "book": 40, "chapter": 1, "verse": 1, "text": "¶ KSIĘGA początku Jezusa Chrystusa..." }, ... ] } ``` Books 40-43 correspond to the four Gospels: - 40: Matthew (Mateusza) - 41: Mark (Marek) - 42: Luke (Łukasz) - 43: John (Jana) ## Date-Based Algorithm The program calculates reading position as follows: 1. **Day of Year**: Get current day number (1-366) 2. **Verse Offset**: Multiply by 12 verses per day: `offset = (day_of_year - 1) × 12` 3. **Modulo Wrap**: Apply modulo with total Gospel verses (3779) to cycle yearly 4. **Position Mapping**: Walk through Gospels to find corresponding verses 5. **Lookahead Rule**: Extend to chapter end if less than 12 verses remain ## Project Structure ``` . ├── cmd/bibel.go # Main CLI entry point ├── configs/ # Default configuration files │ └── config.example.toml # The default configuration file ├── internal/ │ ├── config.go # Reading and writing to config │ ├── dateprogression.go # Date-based position calculation │ ├── verse.go # Data structures │ ├── loader.go # JSON loading and indexing │ ├── formatter.go # Output formatting │ └── tui/ # Terminal User Interface │ └── model.go # bubbletea TUI model and styling ├── books/pol_nbg.json # Bible data ├── go.mod # Go module dependencies └── go.sum # Go dependency checksums ``` ## Examples - **1 January**: Matthew 1:1-12 - **2 January**: Matthew 1:13-25 (extends to end of chapter) - **16 April**: Mark 5:41-43 - **31 December**: Matthew 18:7-18 (year wraps around) ## Development ```bash # Build go build ./cmd/bibel.go # Run ./bibel ```