Metadata-Version: 2.1
Name: caep
Version: 0.0.5
Summary: Config Argument Env Parser (CAEP)
Home-page: https://github.com/mnemonic-no/caep
Author: mnemonic AS
Author-email: opensource@mnemonic.no
License: ISC
Keywords: mnemonic
Classifier: Development Status :: 4 - Beta
Classifier: Topic :: Utilities
Classifier: License :: OSI Approved :: ISC License (ISCL)
Requires-Python: >=3.6, <4
Description-Content-Type: text/markdown
License-File: LICENSE

# CAEP

config module, supports loading config from ini, environment and arguments

The configuration presedence are (from lowest to highest):
* argparse default
* ini file
* environment variable
* command line argument

# Config

Arguments are parsed in two phases. First, it will look for the argument --config argument
which can be used to specify an alternative location for the ini file. If not --config argument
is given it will look for an ini file in the following locations (~/.config has presedence):

- ~/.config/<CONFIG_ID>/<CONFIG_FILE_NAME> (or directory specified by XDG_CONFIG_HOME)
- /etc/<CONFIG_FILE_NAME>

The ini file can contain a "[DEFAULT]" section that will be used for all configurations.
In addition it can have a section that corresponds with <SECTION_NAME> that for
specific configuration, that will over override config from DEFAULT

# Environment variables

The configuration step will also look for environment variables in uppercase and
with "-" replaced with "_". For the example below it will lookup the following environment
variables:

- $NUMBER
- $BOOL
- $STR_ARG

Example:

```
>>> import caep
>>> import argparse
>>> parser = argparse.ArgumentParser("test argparse")
>>> parser.add_argument('--number', type=int, default=1)
>>> parser.add_argument('--bool', action='store_true')
>>> parser.add_argument('--str-arg')
>>> args = caep.config.handle_args(parser, <CONFIG_ID>, <CONFIG_FILE_NAME>, <SECTION_NAME>)
```
