# `Apero.Conf`
[🔗](https://github.com/Lorenzo-SF/apero/blob/3.0.0/lib/apero/conf.ex#L1)

Configuration file management — unified interface for JSON, YAML and TOML.

Provides operations for loading, validating, writing and merging config files
regardless of their format. The format is auto-detected from the file extension
and can be explicitly specified.

For `.env` files and environment variables, use `Apero.Env`.

# `format`

```elixir
@type format() :: :json | :yaml | :toml
```

# `detect_format`

```elixir
@spec detect_format(Path.t()) :: format()
```

Detects the config format from a file extension.

# `encode`

```elixir
@spec encode(map(), format()) :: {:ok, String.t()} | {:error, term()}
```

Serializes a map to a config string.

# `get`

```elixir
@spec get(map(), String.t()) :: term()
```

Gets a nested value from a config map using dot-separated key path.

## Examples

    iex> Conf.get(%{retrieval: %{vector_weight: 0.5}}, "retrieval.vector_weight")
    0.5

    iex> Conf.get(%{foo: 1}, "bar")
    nil

# `load`

```elixir
@spec load(
  Path.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}
```

Loads a config file. Format is auto-detected from extension.

# `merge`

```elixir
@spec merge([map()]) :: map()
```

Merges a list of config maps. Later entries override earlier ones.

# `parse`

```elixir
@spec parse(String.t(), format()) :: {:ok, map()} | {:error, term()}
```

Parses a config string in the given format.

# `print_summary`

```elixir
@spec print_summary(map(), String.t()) :: :ok
```

Prints a formatted summary of a config map to the terminal.

# `set`

```elixir
@spec set(map(), String.t(), term()) :: map()
```

Sets a nested value in a config map using dot-separated key path.

Returns an updated config map (immutable — original is not modified).

## Examples

    iex> Conf.set(%{retrieval: %{vector_weight: 0.5}}, "retrieval.vector_weight", 0.8)
    %{retrieval: %{vector_weight: 0.8}}

# `validate`

```elixir
@spec validate(map(), map()) :: :ok | {:error, [String.t()]}
```

Validates a config map against a schema map (shallow key-type check).

# `write`

```elixir
@spec write(Path.t(), map(), keyword()) :: :ok | {:error, term()}
```

Writes a map to a config file.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
