feat: Default env variables
This commit is contained in:
21
README.md
21
README.md
@@ -185,6 +185,27 @@ let command = cmd!(
|
||||
assert_eq!(format!("{command:?}"), r#"NEW_VAR="new_var" TEST="test" "echo" "test""#);
|
||||
```
|
||||
|
||||
#### Conditional
|
||||
You can have a default value set for an environment variable.
|
||||
|
||||
```rust
|
||||
use comlexr::cmd;
|
||||
|
||||
const NEW_VAR: &str = "NEW_VAR";
|
||||
std::env::set_var("TEST", "realvalue");
|
||||
|
||||
let command = cmd!(
|
||||
env {
|
||||
"TEST":? "test",
|
||||
NEW_VAR: "new_var"
|
||||
};
|
||||
"echo",
|
||||
"test",
|
||||
);
|
||||
|
||||
assert_eq!(format!("{command:?}"), r#"NEW_VAR="new_var" "echo" "test""#);
|
||||
```
|
||||
|
||||
#### Current Directory and Env Variable Order Matters
|
||||
Environment variable declarations **MUST** come after the current directory declaration.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user