Local-first Bible study CLI

Lex CLI Docs

Lex reads Scripture, searches local Bible databases, opens interlinear study views, maps cross-references, browses creeds, and exports study work from the terminal.

Version 2.5 Offline SQLite/JSON runtime data macOS/Linux terminal workflow

Install And Update

The recommended install is a full Git checkout because Lex depends on a large local runtime data bundle.

git clone https://github.com/elcafe7/lex.git
cd lex
./setup.sh

setup.sh creates a repo-local virtual environment and writes a lex wrapper into ~/.local/bin. That wrapper runs the checkout's lex.py directly.

Update Code

git pull
./setup.sh

Update Runtime Data

lex update

lex update is data-only. It syncs manifest-tracked files under runtime-data/ and does not overwrite CLI code.

Reference Syntax

References are intentionally forgiving. Full names, common abbreviations, compact references, and chapter-only references are accepted.

Single verse

lex John 3:16
lex jn 3:16
lex 2 jn 1:2

Chapter

lex Romans 8
lex read John 1
lex Gen 1

Verse range

lex Romans 8:28-39
lex export "Romans 8:28-39" --mode read --format pptx

One-time Bible selection

lex -B kjv John 3:16
lex -B lxx Genesis 1:1
lex -B vulg John 1:1

Command Reference

This section is exhaustive for the current local command surface. Optional flags can usually appear before or after the reference.

Start, Help, Credits

CommandPurpose
lexOpen the main landing screen.
lex --versionPrint the plain application version for scripts.
lex --creditsShow data credits and source acknowledgements.
lex update or lex --updateRefresh manifest-managed runtime data.

Read Scripture

CommandPurpose
lex John 3:16Read a verse with nearby context.
lex read John 3:16Explicit read command for a verse.
lex Romans 8Read a full chapter.
lex --nextMove to the next verse or chapter from the saved history position.
lex --prevMove to the previous verse or chapter from the saved history position.

History

CommandPurpose
lex historyShow recent Lex commands from the local query history.
lex history --limit 10Show a smaller number of recent commands.
lex history --clearClear the local query history.
lex history clearAlternate clear form.

Study

CommandPurpose
lex study John 1:1Show selected-version context, then source-language study tables, lexicon notes, topical associations, and TSK cross-references.
lex John 3:16 -iQuick study mode using the interlinear flag.
lex study Romans 1:1 --no-animateDisable pauses between study sections.
lex study Romans 1:1 --animateForce pauses between study sections.
lex -B lxx Genesis 1:1 -iExplicit LXX study path. This mode is in progress.
lex -B vulg John 1:1 -iExplicit Vulgate study path. This mode is in progress.
English-version Old Testament study is Masoretic-oriented through the local ESV Hebrew/Aramaic interlinear packet. LXX and Vulgate study data should not auto-populate while studying an English Bible.

Search

CommandPurpose
lex search israelSearch Scripture for a word.
lex search "kingdom of god"Search for a phrase, with all-terms fallback.
lex search israel --page 2Open a specific result page.
lex search israel --limit 25Change result count per page.
lex search covenant -jeremiahScope search to one book.
lex search beast -daniel-revelationScope search to a book range.
lex search resurrection -ntScope search to a canon group.

Supported group scopes include -ot, -old-testament, -nt, -new-testament, -law, -pentateuch, -torah, -history, -wisdom, -poetry, -major, -major-prophets, -minor, -minor-prophets, -prophets, -gospels, -epistles, -letters, -pauline, and -general-epistles.

Verse Web

CommandPurpose
lex web John 3:16Show the verse plus ranked local cross-reference connections.
lex web Romans 1:1 --limit 8Control the number of cross-reference rows.

Topics, Lexicons, Dictionary

CommandPurpose
lex naves graceOpen a Nave's Topical Bible entry.
lex topic graceAlias for Nave's topic lookup.
lex naves John 3:16Find topical associations for a verse.
lex G3056Look up a Strong's Greek number.
lex H7225Look up a Strong's Hebrew number.
lex strongs loveSearch Strong's entries by English gloss.
lex define covenantShow local dictionary and encyclopedia entries.

Commentary And Creeds

CommandPurpose
lex commentary John 3:16Show local commentary notes for a verse.
lex commentary Romans 1Show local commentary notes for a chapter.
lex creedOpen the creed and confession navigator.
lex creed niceneOpen a specific creed or confession by search term.
lex creed westminster confessionOpen a longer historical document by name.

Export

CommandPurpose
lex export "John 3:16"Open an interactive export menu.
lex export "Romans 8:28-39" --mode read --format pptxExport read-mode verses to PPTX.
lex export "Romans 8:28-39" --mode read --format pngExport read-mode verses to PNG images.
lex export "John 1:1" --mode study --format pdfExport study packet as PDF.
lex export "John 1:1" --mode study --format docxExport study packet as DOCX.
lex export "John 3:16" --mode web --format pdfExport verse web data as PDF.
lex export "John 3:16" --mode web --format docxExport verse web data as DOCX.

Interactive Actions

ModeKeys
Studyn next verse, p previous verse, r read context, w verse web, e export, q done.
Search1-10 study result, r # read result, n/p page, e export, q quit.
Creedsn next section, p previous section, m menu, q quit.
ReadVerse and chapter reads expose export actions in interactive terminals.

Exports

Lex writes exports under ~/Documents/lex_exports. Study packets go under ~/Documents/lex_exports/studies. The app tries to open finished files automatically and prints the path if the desktop blocks that.

ModeFormatsNotes
ReadPNG, PPTXUse --ratio 16:9 or --ratio 1:1 for PNG exports.
StudyDOCX, PDFInteractive study export also offers a PPTX verse slide.
SearchDOCX, PDF, PPTXExports the current result page from interactive search.
Verse WebDOCX, PDFExports verse plus cross-reference connection data.

Bible Versions

Lex supports ESV, KJV, KJ16, NASB, Geneva, LXX, and Vulgate runtime databases when present locally.

CommandPurpose
lex -vOpen the interactive Bible version picker.
lex version kjvPersistently set the default Bible version.
lex -v nasbPersistently set the default Bible version by short flag.
lex -B lxx Genesis 1:1Use a Bible version for one command only.

Themes

Lex chooses a theme from explicit flags, environment variables, saved config, terminal hints, and platform appearance.

CommandPurpose
lex -lightPersist Studio Light theme.
lex -darkPersist Blueprint Technical theme.
lex -autoClear saved theme and return to automatic detection.
LEX_THEME=dark lex John 3:16Override the theme for one command.
LEX_NO_COLOR=1 lex John 3:16Disable Lex color intentionally.

Troubleshooting

SymptomWhat To Check
lex not foundConfirm ~/.local/bin is on PATH and rerun ./setup.sh.
Wrong checkout runningRun type -a lex and head -5 ~/.local/bin/lex.
No reference resultTry the full book name, such as lex 1 Corinthians 13.
No study dataThe verse can still be read, but study requires the matching local source-language dataset.
Missing encyclopedia entryThe local ISBE import is incomplete and currently covers only part of the source material.

Developer Backend Overview

lex.py is the active tracked CLI. It owns argument parsing, local SQLite access, JSON loading, terminal rendering, update checks, export generation, and interactive action loops.

Entry Point

main() parses CLI flags and dispatches to LexAgent methods.

Database Wrapper

LexDB is a small SQLite query helper used by read, search, study, creeds, and dictionaries.

Runtime Agent

LexAgent resolves references, opens data stores, lazily loads JSON, renders output, and handles exports.

State

Last navigation position is stored in ~/.lex_history. Recent command history is stored in ~/.lex_query_history. Theme config is stored in ~/.lex_config.json.

Runtime Data

A normal checkout resolves data under runtime-data/. If the runtime bundle is absent, Lex can fall back to ~/bible-lexicon-data for local developer worktrees.

PathUse
runtime-data/lexicon.dbLegacy combined data and update sentinel.
runtime-data/bible_versions/*.dbPer-edition Bible text for read and search.
runtime-data/esv-data/data/esv/esv-interlinear.jsonESV-backed Hebrew/Greek interlinear rows.
runtime-data/esv-data/data/interlinear/strongs.jsonInterlinear Strong's metadata.
runtime-data/lxx.dbIn-progress LXX morphology study data.
runtime-data/cross_refs.dbTreasury of Scripture Knowledge cross-reference graph.
runtime-data/strongs.dbStrong's lookup data.
runtime-data/dictionary.dbDictionary entries.
runtime-data/encyclopedia.dbISBE encyclopedia entries.
runtime-data/creeds.dbCreed/confession index rows.
runtime-data/theolog-ai/data/historical-documentsJSON fallback for full creed/confession texts.

Study Boundaries

Study mode has an important source-tradition boundary.

  • Render the selected Bible version as the context panel first.
  • English Old Testament study remains Masoretic-oriented through ESV Hebrew/Aramaic interlinear data.
  • LXX study is a separate, in-progress path selected explicitly with -B lxx.
  • Vulgate study is a separate, in-progress path selected explicitly with -B vulg.
  • Do not populate LXX or Vulgate study rows while the selected Bible is English.
  • Do not fall back across source traditions by matching only book/chapter/verse suffixes.

CLI Dispatch

main() keeps command routing thin. Feature behavior should live on LexAgent methods.

RouteBackend Method
read or bare referencedisplay_verse() / render_chapter()
study or -idisplay_verse(..., interlinear=True) then display_study()
webdisplay_verse_web()
searchdisplay_search()
naves / topicdisplay_naves()
strongs / G#### / H####display_strongs() or English Strong's search
defineDictionary plus encyclopedia lookup
creeddisplay_creed_navigator()
exportprompt_bulk_export() or handle_bulk_export()

Verification

Minimum local checks after CLI changes:

python3 -m py_compile ./lex.py
python3 ./lex.py --version
python3 ./lex.py read John 3:16
python3 ./lex.py study Genesis 1:1 --no-animate
python3 ./lex.py -B lxx Genesis 1:1 -i --no-animate
python3 ./lex.py search israel --limit 2
python3 ./lex.py define heliodorus

Before changing install behavior, verify the local wrapper target:

type -a lex
head -5 ~/.local/bin/lex