(sph config)

program configuration file management. deprecated

use (sph lang config) instead

configuration options stored in multiple files

configuration path setting per environment variable

the default configuration path is currently $PWD/config/default.scm but can be set with config-load

was written to be able to select configuration files at run-time

preliminary support for persisting run-time modified configurations

additional custom config-loaders and config-savers could be integrated

config file format

public-app-name "test"
listen-port 6500
listen-address "::1"
development #t

allows all scheme syntax supported by guile "read"

implicitly quasiquoted flat association list

examples for loading configuration

(config-load "default")
(config-load hashtable)
(config-load "default" (quote default) (quote ((path . "/home/username/.config/program-name/"))))

configuration value access

(config-ref listen-port)

using an unquoted symbol (alternative arguments are possible using other bindings)

nested hashtable references are possible

(config-ref url backend api)

possible enhancements

compile-time configuration

moving the second config-load argument into the options alist


using "define" and (include "/path/to/config"). code-duplication if the include is used multiple times

a module could be used that includes a file, and exports the configuration variables. but since include is a macro, the module or any other file using it needs to be recompiled if the configuration changes (also mentioned here gnu.org/software/guile/manual/html_node/Compilation.html. it seems this may be solved in the future, then this module may be extended to support static configuration

using "load", read/write and eval

using a module and load the module at run-time

tags: programming guile documentation library scheme sph-lib config