From 93f7d1fe99c6590c3d9fb48326aef9a294ca31da Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 27 Jul 2026 13:11:27 +0200 Subject: config: self-documenting default config.ini (reference header) as single source renderConfigINI now emits a top-of-file reference block listing each option's allowed values (full-line comments; ascension/corpus_christi note the 'following Sunday' transfer). seedIfMissing generates from renderConfigINI, so the seed, migrated configs, and web-settings saves all carry the same header; dropped the separate embedded config.ini. --- internal/config/config.go | 44 ++++++++++++++++++++++++++++++++++++-------- internal/config/config.ini | 26 -------------------------- 2 files changed, 36 insertions(+), 34 deletions(-) delete mode 100644 internal/config/config.ini diff --git a/internal/config/config.go b/internal/config/config.go index 78e364c..913962b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -9,7 +9,6 @@ package config import ( - _ "embed" "fmt" "os" "path/filepath" @@ -23,11 +22,39 @@ import ( "github.com/lukaszkasprzak/lectio/internal/ini" ) -// seedINI is the embedded default config.ini, written to disk on first run and -// parsed as the fallback default values. -// -//go:embed config.ini -var seedINI []byte +// configHeader is the reference comment block written at the top of every +// generated config.ini (the first-run seed and every Save), documenting each +// option's allowed values. Full-line comments only, so the INI reader skips +// them and values stay verbatim. +const configHeader = `# lectio configuration (INI). Full-line comments only (# or ;); no inline comments. +# Lists are comma-separated. Booleans are true/false. +# +# Allowed values: +# lectionary new | traditional (new = modern OF; traditional = 1962 EF) +# traditional_lang pl | en (vernacular for traditional propers) +# versions any of: bt, wuj, vul, grb, drb (comma list; bt = Biblia Tysiąclecia) +# default_version bt | wuj | vul | grb | drb +# width integer; 0 = detect terminal width +# all true | false (all readings, or just the gospel) +# offline true | false (never fetch; cache/sigla only) +# ui_language en | pl (interface chrome; readings stay source-language) +# sigla_style auto | polish | english (citation dialect; auto follows ui_language) +# web_theme a theme name (see docs/THEMES.md) +# web_port integer; 0 = try 1099, then any free port +# web_display horizontal | vertical | interlinear +# web_mono true | false (monospace reading face in the web UI) +# web_versions any of: bt, wuj, vul, grb, drb (comma list); empty = just default_version +# pager shell command, e.g. less -R; empty = off +# +# [calendar] — computed-calendar placement options (defaults = Universal Roman Calendar): +# epiphany fixed | sunday (fixed = Jan 6; sunday = the Sunday of Jan 2-8) +# ascension thursday | sunday (sunday = moved to the following Sunday, 7th of Easter) +# corpus_christi thursday | sunday (sunday = moved to the following Sunday) +# +# Optional [parts.new] / [parts.traditional] sections hide reading parts, e.g.: +# [parts.new] +# psalm = false +` // Version is lectio's release version, shared by every binary's // -v/--version output (lectio, lectio-ui, lectio-web). @@ -264,7 +291,7 @@ func seedIfMissing(path string) error { if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { return err } - return os.WriteFile(path, seedINI, 0o644) + return os.WriteFile(path, renderConfigINI(Default()), 0o644) } // migrateFromTOML converts a former config.toml sitting next to iniPath into @@ -466,7 +493,8 @@ func Save(cfg Config) error { // lines so no value ever shares a line with a "#"/";" comment character. func renderConfigINI(cfg Config) []byte { var b strings.Builder - b.WriteString("# lectio configuration (INI). Lists are comma-separated; booleans true/false.\n\n") + b.WriteString(configHeader) + b.WriteString("\n") fmt.Fprintf(&b, "schema_version = %d\n", cfg.SchemaVersion) fmt.Fprintf(&b, "lectionary = %s\n", cfg.Lectionary) fmt.Fprintf(&b, "traditional_lang = %s\n", cfg.TraditionalLang) diff --git a/internal/config/config.ini b/internal/config/config.ini deleted file mode 100644 index 1e5ed94..0000000 --- a/internal/config/config.ini +++ /dev/null @@ -1,26 +0,0 @@ -# lectio configuration (INI). -# Interface/behavior settings; the computed liturgical calendar reads the -# [calendar] section. Lists are comma-separated. Booleans are true/false. - -schema_version = 1 -lectionary = new -traditional_lang = pl -versions = bt, wuj, vul, grb, drb -default_version = bt -width = 0 -all = false -offline = false -ui_language = en -sigla_style = auto -web_theme = transfiguration -web_port = 0 -web_display = horizontal -web_mono = false -web_versions = -pager = - -# Computed-calendar national placement options (defaults = Universal Roman). -[calendar] -epiphany = fixed -ascension = thursday -corpus_christi = thursday -- cgit v1.3