simple_config

JSON-Based Configuration Management for Eiffel

v1.0.0 MIT

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

  1. Set the environment variable:
    export SIMPLE_EIFFEL=/d/prod
  2. 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

FeatureDescription
makeCreate empty config
make_with_file (path)Load from JSON file
loadReload from file
merge_file (path)Merge another config

String Access

FeatureDescription
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

FeatureDescription
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

FeatureDescription
set_string (key, value)Set string value
set_integer (key, value)Set integer value
set_boolean (key, value)Set boolean value
saveSave to file
save_to (path)Save to new file

Documentation