kpfleming
(Kevin P. Fleming)
July 15, 2022, 10:38am
1
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?
abravalheri
(Anderson Bravalheri)
July 15, 2022, 3:16pm
2
They might be not the most elegant solutions but I did hack something before using all of the following methods:
argparse’s buitin fromfile_prefix_chars .
click’s Context.default_map - see also complex application
The “overkill” OmegaConf - when using this one I always tend to use dataclasses to add some structure/validation .
kpfleming
(Kevin P. Fleming)
July 15, 2022, 6:28pm
3
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