{"id":25839284,"url":"https://github.com/askoretskiy/readenv","last_synced_at":"2025-03-01T04:26:20.818Z","repository":{"id":62443768,"uuid":"259104781","full_name":"askoretskiy/readenv","owner":"askoretskiy","description":"Simple program that reads .env file and use it to run given command","archived":false,"fork":false,"pushed_at":"2023-03-05T19:25:32.000Z","size":16,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T23:47:39.578Z","etag":null,"topics":["cli-app","dotenv","env","rust-lang"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/askoretskiy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-26T18:32:59.000Z","updated_at":"2023-08-22T05:04:43.000Z","dependencies_parsed_at":"2022-11-01T22:16:43.949Z","dependency_job_id":null,"html_url":"https://github.com/askoretskiy/readenv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askoretskiy%2Freadenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askoretskiy%2Freadenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askoretskiy%2Freadenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askoretskiy%2Freadenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/askoretskiy","download_url":"https://codeload.github.com/askoretskiy/readenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241096515,"owners_count":19908994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli-app","dotenv","env","rust-lang"],"created_at":"2025-03-01T04:26:20.270Z","updated_at":"2025-03-01T04:26:20.813Z","avatar_url":"https://github.com/askoretskiy.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ReadEnv\n\nSimple program that reads `.env` file and use it to run given command.\n\nNever load environment variables manually or pollute your interpreter profile again. \n\n## How it works\n\n1. Read current environment variables\n2. Read `.env` file in current or parent directory\n3. Extend current environment variables with ones read from `.env` file\n4. Spawn `\u003cCOMMAND\u003e` with generated environment variables\n5. Replace current process with spawned one\n\n## Installation\n\n```\ncargo install readenv\n```\n\n## Usage\n\n1. Create `.env` file in with `\u003cKEY\u003e=\u003cVALUE\u003e` structure in current or parent directory\n2. Run the app:\n\n   ```bash\n   renv \u003cCOMMAND\u003e\n   ```\nDuring the run, the `\u003cCOMMAND\u003e` acts exactly as executed directly, including environment variables, stdin, stdout, stderr, pipelines support and signals handling.\n\n## .env format\n\nSupport of `.env` file is provided by [dotenv](https://github.com/dotenv-rs/dotenv) library. See its [documentation](https://crates.io/crates/dotenv) for the format.\n\n## Recipes\n\n### Django\n\nTo run a [Django](https://www.djangoproject.com/) project, a settings file is needed. One approach is to have\ndifferent settings file per enviroment (e.g. for development and production).\n\nThe easiest way to do that is to define environment variable `DJANGO_SETTINGS_MODULE` with name of the settings module.\n\nLet's create `.env` file (given settings module is `local_settings`):\n\n```bash\necho 'DJANGO_SETTINGS_MODULE=local_settings' \u003e\u003e .env\n```\n\nNow run Django server with one command:\n\n```bash\nrenv django-admin.py runserver\n```\n\n### Virtualenv\n\n[Virtualenv](https://virtualenv.pypa.io/en/latest/) is a nice tool to isolate Python dependencies for a project.\n\nTo switch to given virtualenv one has to use command `. \u003cVENV\u003e/bin/activate`.\n\nLet's create `.env` file (given virtualenv directory is `.venv`):\n\n```bash\necho \"VIRTUAL_ENV=$PWD/.venv\" \u003e\u003e .env\necho \"PATH=$PWD/.venv/bin:\\${PATH}\" \u003e\u003e .env\n```\n\nNow check Python interpreter:\n\n```bash\nrenv which python\n```\n\nResult should be:\n\n```bash\n$PWD/.venv/bin/python\n```\n\nTry pip:\n\n```bash\nrenv pip freeze\n```\n\nResult should be the list of dependencies installed in your virtualenv.\n\n## Design considerations\n\n[12-factor App methodology](https://en.wikipedia.org/wiki/Twelve-Factor_App_methodology) is great but could be boring.\nA simple tool that automates work with environment variables would be helpful.\n\nThat tool should be a drop-in replacement for any app, so it:\n\n* Must support stdin, stdout and stderr\n* Could be used in pipelines\n* Must handle signals (e.g. `SIGTERM` or `SIGKILL`) identically\n\nAlso, it would be nice to:\n\n* Have small application size\n* Have low RAM footprint\n* Do not depend on shell used\n* Be safe\n\nSolution:\n\n* Produce binary program\n* Use [Rust](https://www.rust-lang.org/)\n* Replace its process with executed command (like `exec` in BASH)\n\n## Kudos\n\nThanks team of [dotenv](https://github.com/dotenv-rs/dotenv) and [dotenv](https://github.com/allan2/dotenvy) library for the most of work ;-)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faskoretskiy%2Freadenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faskoretskiy%2Freadenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faskoretskiy%2Freadenv/lists"}