https://github.com/jiro4989/envconfig
envconfig provides a function to get config objects from environment variables.
https://github.com/jiro4989/envconfig
config environment-variables lib library nim
Last synced: 6 days ago
JSON representation
envconfig provides a function to get config objects from environment variables.
- Host: GitHub
- URL: https://github.com/jiro4989/envconfig
- Owner: jiro4989
- Created: 2020-01-01T16:28:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-06T02:29:37.000Z (10 months ago)
- Last Synced: 2025-03-31T17:50:14.312Z (about 1 month ago)
- Topics: config, environment-variables, lib, library, nim
- Language: Nim
- Homepage: https://jiro4989.github.io/envconfig/envconfig.html
- Size: 73.2 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
#########
envconfig
#########|gh-actions|
envconfig provides a function to get config objects from environment variables.
envconfig is inspired by `Go envconfig `_... contents:: Table of contents
:depth: 3************
Installation
************.. code-block:: Bash
nimble install envconfig
*****
Usage
*****-----
Basic
-----Example that setting environment variables with shell.
.. code-block:: Bash
export MYAPP_NAME=envconfig
export MYAPP_VERSION=v1.0.0
export MYAPP_DIR=/opt/envconfig
export MYAPP_PORT=1234
export MYAPP_DEV=true.. code-block:: Nim
import envconfig
type
MyApp = object
name, version, dir: string
port: int
dev: boollet config = getEnvConfig(MyApp)
echo "MYAPP_NAME: " & config.name # envconfig
echo "MYAPP_VERSION: " & config.version # v1.0.0
echo "MYAPP_DIR: " & config.dir # /opt/envconfig
echo "MYAPP_PORT: " & $config.port # 1234
echo "MYAPP_DEV: " & $config.dev # trueExample that setting environment variables with Nim.
.. code-block:: Nim
import envconfig
from os import putEnvtype
MyApp = object
name, version, dir: string
port: int
dev: boolputEnv("MYAPP_NAME", "envconfig")
putEnv("MYAPP_VERSION", "v1.0.0")
putEnv("MYAPP_DIR", "/opt/envconfig")
putEnv("MYAPP_PORT", "1234")
putEnv("MYAPP_DEV", "true")let config = getEnvConfig(MyApp)
echo "MYAPP_NAME: " & config.name # envconfig
echo "MYAPP_VERSION: " & config.version # v1.0.0
echo "MYAPP_DIR: " & config.dir # /opt/envconfig
echo "MYAPP_PORT: " & $config.port # 1234
echo "MYAPP_DEV: " & $config.dev # true----------
Validation
----------Provides tiny functions to validate values.
A procedure can validate `requires`, `min value`, `max value` and `regex match`.
For more informations, see also `API documents `_.*************
API Documents
************** `envconfig `_
*******
LICENSE
*******MIT
.. |gh-actions| image:: https://github.com/jiro4989/envconfig/workflows/build/badge.svg
:target: https://github.com/jiro4989/envconfig/actions