Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T02:36:59.393Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

env_var.rs

41 lines · 1.1 KB · rust
1use gpui_shared_string::SharedString;
2
3#[derive(Clone)]
4pub struct EnvVar {
5    pub name: SharedString,
6    /// Value of the environment variable. Also `None` when set to an empty string.
7    pub value: Option<String>,
8}
9
10impl EnvVar {
11    pub fn new(name: SharedString) -> Self {
12        let value = std::env::var(name.as_str()).ok();
13        if value.as_ref().is_some_and(|v| v.is_empty()) {
14            Self { name, value: None }
15        } else {
16            Self { name, value }
17        }
18    }
19
20    pub fn or(self, other: EnvVar) -> EnvVar {
21        if self.value.is_some() { self } else { other }
22    }
23}
24
25/// Creates a `LazyLock<EnvVar>` expression for use in a `static` declaration.
26#[macro_export]
27macro_rules! env_var {
28    ($name:expr) => {
29        ::std::sync::LazyLock::new(|| $crate::EnvVar::new(($name).into()))
30    };
31}
32
33/// Generates a `LazyLock<bool>` expression for use in a `static` declaration. Checks if the
34/// environment variable exists and is non-empty.
35#[macro_export]
36macro_rules! bool_env_var {
37    ($name:expr) => {
38        ::std::sync::LazyLock::new(|| $crate::EnvVar::new(($name).into()).value.is_some())
39    };
40}
41
Served at tenant.openagents/omega Member data and write actions are omitted.