"""
ConfigSettings: subclasses pydantic_settings.BaseSettings.

Use this when you want typed fields, validation, nested BaseModel sections, and
the usual settings machinery (e.g. environment variables can still apply for
fields not filled from TOML, per pydantic-settings behavior).

Install: pip install 'pi-conf[pydantic]' (or your package manager equivalent).
"""

from __future__ import annotations

import sys
from pathlib import Path

_ROOT = Path(__file__).resolve().parents[1]
if str(_ROOT) not in sys.path:
    sys.path.insert(0, str(_ROOT))

from pydantic import BaseModel

from pi_conf.config_settings import ConfigDict, ConfigSettings


class Database(BaseModel):
    host: str
    timeout_seconds: int


class DemoSettings(ConfigSettings):
    app_name: str
    port: int
    database: Database

    model_config = ConfigDict(toml_table_header="")


def main() -> None:
    path = Path(__file__).resolve().parent / "sample_config.toml"
    settings = DemoSettings(config_file=path)

    print("ConfigSettings (Pydantic BaseSettings + TOML)")
    print(f"  app_name: {settings.app_name!r}")
    print(f"  port: {settings.port}")
    print(f"  database: {settings.database.model_dump()}")


if __name__ == "__main__":
    main()
