From d911eef5ad823b317c7261c5e26a9dbedc51e613 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 10 Nov 2023 20:05:28 +0100 Subject: [PATCH] Initial --- README.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f9de7b2..e9e3756 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,24 @@ # Envhead -Envhead is a crate that creates environment variable names using a static prefix. The desired prefix is defined in your build script `build.rs`. +Envhead is a crate that creates environment variable names using a static prefix. -### Usage +## Setup +First, you should define the prefix by setting the `ENV_HEAD_PREFIX` environment variable to the desired value. When the `ENV_HEAD_PREFIX` variable is not defined, `ENV` is used as the default prefix. In the following examples, we will use `MY_APP` as the prefix. -First, you should define the prefix in your `build.rs` file. In this example, we will use `MY_APP` as the prefix: +In case you are working with macOS or Linux, you might use Bash like this: -```rust -fn main() { - println!("cargo:rustc-env=ENV_HEAD_PREFIX=MY_APP"); -} +```bash +ENV_HEAD_PREFIX=MY_APP cargo build ``` -When the `ENV_HEAD_PREFIX` variable is not defined, `ENV` is used as the default prefix. +Using an IDE from JetBrains like [RustRover](https://www.jetbrains.com/rust/), you can set the environment variable in the [run configuration](https://www.jetbrains.com/help/rust/cargo-run-debug-configuration.html) and for your [integrated terminal](https://www.jetbrains.com/help/clion/settings-tools-terminal.html). -Then, in your code, you can use the `envhead!` macro to create environment variable names. +Do you use a CI/CD pipeline? You can set the environment variable in your pipeline configuration. Do you build your application in a Docker container? You can set the environment variable in your Dockerfile as well. + +**Please notice:** This setup procedure is required just for the development environment. Your compiled program(s) will not depend on the `ENV_HEAD_PREFIX` environment variable. + +## Usage +Now, in your code, you can use the `envhead!` macro to create environment variable names. ```rust use envhead::envhead;