# `ExGram.Config`
[🔗](https://github.com/rockneurotiko/ex_gram/blob/0.65.0/lib/ex_gram/config.ex#L1)

Configuration helper with environment variable support.

This module provides `get/3` and `get_integer/3` functions that fetch values from
application config, with special handling for `{:system, "VAR"}` tuples to read
from environment variables.

## Example

    # In config.exs
    config :ex_gram, token: {:system, "BOT_TOKEN"}

    # At runtime
    ExGram.Config.get(:ex_gram, :token) # Reads from $BOT_TOKEN env var

# `get`

```elixir
@spec get(atom(), atom(), term() | nil) :: term()
```

Fetches a value from the config, or from the environment if `{:system, "VAR"}`
is provided.

An optional default value can be provided if desired.

## Examples

    iex> {test_var, expected_value} = System.get_env |> Enum.take(1) |> List.first
    ...> Application.put_env(:myapp, :test_var, {:system, test_var})
    ...> ^expected_value = Elixir.ExGram.Config.get(:myapp, :test_var)
    ...> :ok
    :ok

    iex> Application.put_env(:myapp, :test_var2, 1)
    ...> 1 = Elixir.ExGram.Config.get(:myapp, :test_var2)
    1

    iex> :default = Elixir.ExGram.Config.get(:myapp, :missing_var, :default)
    :default

# `get_integer`

```elixir
@spec get_integer(atom(), atom(), integer() | nil) :: integer()
```

Same as `get/3`, but returns the result as an integer.

If the value cannot be converted to an integer, the default is returned instead.

---

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