Metadata-Version: 2.4
Name: envbox
Version: 2.0.0
Summary: Detect environment type and work within.
Project-URL: Homepage, https://github.com/idlesign/envbox
Project-URL: Documentation, https://envbox.readthedocs.io/
Author-email: Igor Starikov <idlesign@yandex.ru>
License-Expression: BSD-3-Clause
License-File: LICENSE
Keywords: backup,webinars
Requires-Python: >=3.10
Provides-Extra: cli
Requires-Dist: click>=2.0.0; extra == 'cli'
Description-Content-Type: text/markdown

# envbox

https://github.com/idlesign/envbox

[![PyPI - Version](https://img.shields.io/pypi/v/envbox)](https://pypi.python.org/pypi/envbox)
[![License](https://img.shields.io/pypi/l/envbox)](https://pypi.python.org/pypi/envbox)
[![Coverage](https://img.shields.io/coverallsCoverage/github/idlesign/envbox)](https://coveralls.io/r/idlesign/envbox)
[![Docs](https://img.shields.io/readthedocs/envbox)](https://envbox.readthedocs.io/)


## Description

*Detect environment type and work within.*

### Features

* Environment type detection (extendable system);
* Support for `.env` files;
* Convenient `os.environ` proxying (with optional values casting into Python natives);
* Automatic submodule-for-environment import tool;
* Cosy per-thread settings container with environment var support;
* CLI for environment probing.


## Code sample

```python
from envbox import get_environment

# Detect current environment type
# and get its object.
#
# Default detection sources:
# 1. ``PYTHON_ENV`` env variable
# 2. ``environment`` file contents
#
# By default this function will also try to read env variables from .env files.
env = get_environment()

env.name
# >> development

env.is_production
# >> False

env.get('HOME')  # The same as env['HOME'] and env.HOME
# >> /home/idle/

env.getmany('PYTHON')
# {'UNBUFFERED': '1', 'IOENCODING': 'UTF-8', 'PATH': ...}
```

## .env files

Now you may want to put your environment vars into `.env` files
(e.g.: `.env`, `.env.development` `.env.production`) to be read by `envbox`:

```dotenv
MY_VAR_1=value1
HOME=/home/other/

# comments are ignored, just as lines without definitions

# mathing quotes (" and ') are stripped
MY_QUOTED="some quoted "

# ${VARNAME} will be replaced by value from env (if available)
MY_VAR_2="${MY_QUOTED}"

# multiline with dangling quotes
MULTI_1="
line1
line2
"

# multiline classic
MULTI_2="line1
line2
line3"

# multiline as one line
MULTI_3="one\ntwo"
```
Read the docs for more examples.


## CLI

```shell
$ envbox probe
# >> Detected environment type: development (Development)

$ envbox show
# >> [...]
# >> SHELL = /bin/bash
# >> [...]
```

!!! note
    `envbox` CLI requires `click` package available.


## Documentation

https://envbox.readthedocs.io/
