Skip to content
Snippets Groups Projects
README.md 1.24 KiB
Newer Older
  • Learn to ignore specific revisions
  • David Huss's avatar
    David Huss committed
    # common-config
    
    
    This is a common configuration library for eigenservice
    
    
    
    Add this dependency to your application e.g. using poetry (ssh-add so you don't have to type the ssh-password over and over):
    
    ```bash
     ssh-add
     poetry add git+ssh://git@code.hfbk.net:4242/id/eigenservice/common-config.git -vvv
    ```
    
    When something changes update it like this:
    
    ```bash
    poetry update common-config
    ```
    
    
    
    Then in the application use something like this as a starting point:
    
    ```python
    #!/usr/bin/env python 
    #-*- coding: utf-8 -*-
    import common_config
    from common_config import initialize_config, read_settings, main
    
    # Name of this application, used in directory names, etc
    
    David Huss's avatar
    David Huss committed
    APPLICATION_NAME = "my_application"
    
    
    # suffix added to the config files (e.g. `00-suffix.toml`)
    SUFFIX = "config"
    
    # Do not change here, just use an override instead
    DEFAULT_CONFIG = """
    [application]
    loglevel = "info"
    level = 9001
    mood = "very"
    """
    
    # Override the global variables in the common-config.common module
    common_config.common.APPLICATION_NAME = APPLICATION_NAME
    common_config.common.SUFFIX           = SUFFIX
    common_config.common.DEFAULT_CONFIG   = DEFAULT_CONFIG
    
    
    if __name__ == "__main__":
       main()
    ```
    
    If people now run that file, they will get an interactive configuration-tool