Package: the_conf
FromthisUne bonne lib de conf doit:

* Offrir une API standardisée pour définir les paramètres qu’attend son programme sous la forme d’un schéma de données.
* Permettre de générer depuis ce schéma les outils de parsing de la ligne de commande et des variables d’env.
* Permettre de générer depuis ce schéma des validateurs pour ces schémas.
* Permettre de générer des API pour modifier la conf.
* Permettre de générer des UIs pour modifier la conf.
* Séparer la notion de configuration du programme des paramètres utilisateurs.
* Pouvoir marquer des settings en lecture seule, ou des permissions sur les settings.
* Notifier le reste du code (ou des services) qu’une valeur à été modifiée. Dispatching, quand tu nous tiens…
* Charger les settings depuis une source compatible (bdd, fichier, api, service, etc).
* Permettre une hiérarchie de confs, avec une conf principale, des enfants, des enfants d’enfants, etc. et la récupération de la valeur qui cascade le long de cette hiérarchie. Un code doit pouvoir plugger sa conf dans une branche de l’arbre à la volée.
* Fournir un service de settings pour les architectures distribuées.
* Etre quand même utile et facile pour les tous petits scripts.
* Auto documentation des settings.Beforehand: for more claritythe_confwill designate the current program, its configuration will be referred to as themeta confand the configurations it will absorb (files / cmd line / environ) simply as theconfigurations.1. read themeta confthe_confshould provide a singleton.
On instantiation the singleton would read themeta conf(its configuration) from a file. YML and JSON will be considered first. This file will provide names, types, default values and if needed validator for options.the_confwill the validate the conf file. For each config value :if value haschoicesanddefault value,default valuehas to be amongchoices.if the value is nested, a node can't hold anything else than valuesrequiredvalues can't have default2. read theconfigurationsOnce themeta confhas been processed,the_confwill assemble all values at its reach from several sources.
Three types are to be considered:files (again YML/JSON but maybe also later ini)command lineenviron
in this order of importance. This order must be itself overridable.the_confmust provide a backend for values from the configuration to be reached.the_conf.load('path/to/meta/conf.yml')the_conf.nested.value>1Upon readingconfigurations,the_confwill validate gathered values.configurationsfile type will be guessed from file extention (yaml / yml, json, ini), anything else must raise an error. Parsing errors won't also be silenced. Although, missing won't be an issue as long as all required values are gathered.values must be in the type there declared in or cast to it without errorrequired values must be providedif a value is configured withchoices, the gathered value must be inchoicesThe first writable, readable availableconfigurationfile found will be set as the main. Values will be edited on it but values from it will still be overridden according to the priorities. A warning should be issued if the mainconfigurationis overriddable.
If no suitable file is found, a warning should also be issued ; edition will be impossible and will generate an error.3. generate theconfigurationsProvide an API to list and validate values needed from theconfigurations(the required ones).
Provide a command line UI to process that list to let a user generate aconfigurationfile.4. write theconfigurationsDepending on the permissions set in themeta conf,the_confmust allow to edit the values in the configuration file set asmainon read phase.
If editing a value which will be ignored for being overriden, a warning must be issued.