Package for config and argument handling?

I need to build a new tool, and it needs to handle command line arguments (for which I’ll use argparse) and have a configuration file.

Anyone have recommendations for packages that combine these two things so that configurable options can be supplied either way?

They might be not the most elegant solutions but I did hack something before using all of the following methods:

  1. argparse’s buitin fromfile_prefix_chars.
  2. click’s Context.default_map - see also complex application
  3. The “overkill” OmegaConf - when using this one I always tend to use dataclasses to add some structure/validation.

Thanks! I’m going to experiment with ConfigArgParse, as it’s lightweight and the eventual deployment target for this code is relatively small systems (like OpenWrt devices).

1 Like