forked from vieter-v/vieter
doc(env): added missing docstring & README
parent
055b168ff1
commit
d4c803c41c
|
@ -0,0 +1,7 @@
|
|||
This module provides a framework for parsing a configuration, defined as a
|
||||
struct, from both a TOML configuration file & environment variables. Some
|
||||
notable features are:
|
||||
|
||||
* Overwrite values in config file using environment variables
|
||||
* Allow default values in config struct
|
||||
* Read environment variable value from file
|
|
@ -11,6 +11,11 @@ const (
|
|||
file_suffix = '_FILE'
|
||||
)
|
||||
|
||||
// get_env_var tries to read the contents of the given environment variable. It
|
||||
// looks for either `${env.prefix}${field_name.to_upper()}` or
|
||||
// `${env.prefix}${field_name.to_upper()}${env.file_suffix}`, returning the
|
||||
// contents of the file instead if the latter. If both or neither exist, the
|
||||
// function returns an error.
|
||||
fn get_env_var(field_name string) ?string {
|
||||
env_var_name := '$env.prefix$field_name.to_upper()'
|
||||
env_file_name := '$env.prefix$field_name.to_upper()$env.file_suffix'
|
||||
|
|
Loading…
Reference in New Issue