Add generic INI config parser and resolution chain #2

Closed
opened 2026-03-16 17:56:53 +01:00 by michael · 0 comments
Owner

Generic INI config parser and config resolution chain for all DAW projects.

Background

An INI parser exists in DAW/furt (src/config_parser.lua) but is tightly
coupled to furt-specific validation (server, api_keys, smtp_default).
Two things need to be split out into daw-lua-common:

  1. A generic INI parser (no project-specific validation)
  2. A generic config resolution chain (CLI > env > user config > system config)

Deliverables

  • src/daw/lua/common/config.lua

API

local config = require("daw.lua.common.config")

local cfg = config.load({
  env_var  = "STEURJAN_DATA_PATH",
  cli_args = arg,
  cli_flag = "--data-dir",
  paths    = {
    os.getenv("HOME") .. "/.config/steurjan/steurjan.conf",
    "/usr/local/etc/steurjan/steurjan.conf",
    "/etc/steurjan/steurjan.conf",
  }
})

config.load() returns a plain key-value table. No validation --
that is the responsibility of the calling project.

Rules

  • parse_file() returns a plain nested table (section -> key -> value)
  • Type conversion: numbers and booleans are converted, rest stays string
  • No hardcoded sections or required fields
  • Resolution chain stops at first match
  • Hard abort (error) if nothing found -- no silent defaults
  • INI format only (nginx-style sections: [section])

Reference

Resolution chain defined in: DAW/steurjan#25
Existing parser to adapt: DAW/furt (src/config_parser.lua)

Generic INI config parser and config resolution chain for all DAW projects. ## Background An INI parser exists in DAW/furt (src/config_parser.lua) but is tightly coupled to furt-specific validation (server, api_keys, smtp_default). Two things need to be split out into daw-lua-common: 1. A generic INI parser (no project-specific validation) 2. A generic config resolution chain (CLI > env > user config > system config) ## Deliverables - `src/daw/lua/common/config.lua` ## API ```lua local config = require("daw.lua.common.config") local cfg = config.load({ env_var = "STEURJAN_DATA_PATH", cli_args = arg, cli_flag = "--data-dir", paths = { os.getenv("HOME") .. "/.config/steurjan/steurjan.conf", "/usr/local/etc/steurjan/steurjan.conf", "/etc/steurjan/steurjan.conf", } }) ``` `config.load()` returns a plain key-value table. No validation -- that is the responsibility of the calling project. ## Rules - `parse_file()` returns a plain nested table (section -> key -> value) - Type conversion: numbers and booleans are converted, rest stays string - No hardcoded sections or required fields - Resolution chain stops at first match - Hard abort (error) if nothing found -- no silent defaults - INI format only (nginx-style sections: `[section]`) ## Reference Resolution chain defined in: DAW/steurjan#25 Existing parser to adapt: DAW/furt (src/config_parser.lua)
michael 2026-03-16 18:25:26 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/daw-lua-common#2
No description provided.