fabro/lib/crates/fabro-util/src/browser.rs
Bryan Helmkamp 80de5ca616 refactor(static): centralize env var names
Add fabro-static::EnvVars as the shared registry for fixed environment variable names and migrate env reads, clap env bindings, and subprocess/test allowlists to use it.

Add clippy bans for raw std::env lookup APIs so future dynamic env facades must be documented explicitly.
2026-04-24 12:29:51 -04:00

16 lines
569 B
Rust

use fabro_static::EnvVars;
/// When this environment variable is set to any value, [`try_open`] returns
/// `Ok(())` without launching a browser. Test harnesses set it so spawned
/// `fabro` subprocesses do not pop real browser windows during CI or local
/// runs.
#[expect(
clippy::disallowed_methods,
reason = "Browser launching checks the documented process-env escape hatch."
)]
pub fn try_open(url: &str) -> std::io::Result<()> {
if std::env::var_os(EnvVars::FABRO_SUPPRESS_OPEN_BROWSER).is_some() {
return Ok(());
}
open::that(url)
}