Overview
simple_config provides easy JSON-based configuration for Eiffel applications with dot-notation access and environment variable support.
Part of the Simple Eiffel ecosystem.
Quick Start
Installation
- Set the environment variable:
export SIMPLE_EIFFEL=/d/prod - Add to your ECF file:
<library name="simple_config" location="$SIMPLE_EIFFEL/simple_config/simple_config.ecf"/>
config.json
{
"database": {
"host": "localhost",
"port": 5432,
"name": "mydb"
},
"features": {
"debug": true,
"cache_size": 1024
}
}
Usage
local
config: SIMPLE_CONFIG
do
create config.make_with_file ("config.json")
-- Dot notation access
print (config.string_value ("database.host"))
print (config.integer_value ("database.port"))
print (config.boolean_value ("features.debug"))
-- With defaults and env vars
port := config.integer_value_or_env ("database.port", "DB_PORT", 5432)
end
Key Features
Dot Notation
Access nested values: "database.host" navigates JSON structure.
Environment Fallback
Config values can fall back to environment variables.
Type-Safe Access
String, integer, boolean, real, and array accessors.
File Merging
Merge multiple config files for environment overrides.
API Summary
Loading
| Feature | Description |
|---|---|
make | Create empty config |
make_with_file (path) | Load from JSON file |
load | Reload from file |
merge_file (path) | Merge another config |
String Access
| Feature | Description |
|---|---|
string_value (key) | Get string |
string_value_or_default (key, default) | Get with default |
string_value_or_env (key, env_var) | Get from config or env |
Other Types
| Feature | Description |
|---|---|
integer_value (key) | Get integer |
boolean_value (key) | Get boolean |
real_value (key) | Get real/double |
string_list (key) | Get string array |
section (key) | Get nested section |
Modification
| Feature | Description |
|---|---|
set_string (key, value) | Set string value |
set_integer (key, value) | Set integer value |
set_boolean (key, value) | Set boolean value |
save | Save to file |
save_to (path) | Save to new file |
Documentation
- User Guide - Complete tutorial with examples
- API Reference - Full API with contracts
- Architecture - Internal design and rationale
- Cookbook - Ready-to-use recipes and patterns