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:
Ian Douglas Scott 2024-10-14 19:44:22 -07:00 committed by Victoria Brekenfeld
parent a4d875e35e
commit 087be20365
3 changed files with 10 additions and 10 deletions

6
src/utils/env.rs Normal file
View 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()))
}

View file

@ -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;