Initial
This commit is contained in:
parent
593e5beafc
commit
d911eef5ad
22
README.md
22
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;
|
||||
|
Loading…
Reference in New Issue
Block a user