CLI Config

Lightweight library that provides routines to merge your configs (optionally nested) and set parameters from command line. It also prevents you from adding new parameters if not desired. Finally, it provides helper routines to manage flatten dicts, unflatten (= nested) dicts or a mix of both, save config, load, display, etc.

PyPI version PythonVersion License

Ruff_logo Black_logo

Ruff Flake8 Pydocstyle MyPy PyLint

Tests Coverage Documentation Status

Make a default config file in your project (configs are merged from left to right):

# main.py
from cliconfig import make_config

config = make_config('default1.yaml', 'default2.yaml')  # it's a dict

Then launch your script with additional config(s) file(s) and parameters. By default, these additional configs cannot add new parameters to the default config (for security and retro-compatibility reasons).

python main.py --config first.yaml,second.yaml --param1 1 --subconfig.param2 'foo'