Metadata-Version: 2.4
Name: moat-lib-config
Version: 0.1.2
Summary: Configuration management for MoaT applications
Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
Project-URL: homepage, https://m-o-a-t.org
Project-URL: repository, https://github.com/M-o-a-T/moat
Keywords: MoaT
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AnyIO
Classifier: Framework :: Trio
Classifier: Framework :: AsyncIO
Classifier: Programming Language :: Python :: 3
Classifier: Intended Audience :: Developers
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: moat-util~=0.62.3
Requires-Dist: pydantic~=2.12
Requires-Dist: pydantic_variants~=0.3
Dynamic: license-file

# Configuration management

% start main
% start synopsis

This module provides infrastructure for loading, merging, and managing
configuration data from multiple sources. It includes:

- Multi-source configuration loading (files, environment, programmatic)
- Hierarchical configuration with automatic merging
- Context-aware configuration access
- Configuration inheritance with `$base` references
- Lazy loading of module-specific configurations

% end synopsis

% end main

## Usage

```python
from moat.lib.config import CFG

# Initial setup (once, at program startup)
CFG(name="myapp")
# loads `/etc/myapp.yaml` (and others)

# Access configuration data
print(CFG.database.host)
```

## Configuration Sources

The `CfgStore` class combines configuration from multiple sources (in order of precedence):

- Command-line arguments (via `mod` method)
- Preloaded configuration (passed to constructor)
- Environment variables (in `CfgStore.env`)
- Explicitly added config files (via `add` method)
- Default config files (from standard paths)
- Static module configurations (loaded via `with_`)

