Add util function for boolean env vars
It's probably good to be consistent about what is recognized as "true" without copying the same code.
This commit is contained in:
parent
a4d875e35e
commit
087be20365
3 changed files with 10 additions and 10 deletions
6
src/utils/env.rs
Normal file
6
src/utils/env.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
pub fn bool_var(name: &str) -> Option<bool> {
|
||||
let value = std::env::var(name).ok()?.to_lowercase();
|
||||
Some(["1", "true", "yes", "y"].contains(&value.as_str()))
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
pub mod env;
|
||||
mod ids;
|
||||
pub(crate) use self::ids::id_gen;
|
||||
pub mod geometry;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue