Skip to main content

tempo_ext/
lib.rs

1//! Extension dispatch and management for the Tempo CLI.
2
3#![cfg_attr(not(test), warn(unused_crate_dependencies))]
4#![cfg_attr(docsrs, feature(doc_cfg))]
5
6mod installer;
7mod launcher;
8mod registry;
9
10pub use installer::InstallerError;
11pub use launcher::{LauncherError, run};
12
13/// Returns installed extensions as `(name, description)` pairs, sorted alphabetically.
14///
15/// Returns an error if the registry file exists but cannot be read or parsed.
16pub fn installed_extensions() -> Result<Vec<(String, String)>, String> {
17    let reg = registry::Registry::load()?;
18    let mut exts: Vec<(String, String)> = reg
19        .extensions
20        .into_iter()
21        .filter(|(_, state)| !state.installed_version.is_empty())
22        .map(|(name, state)| (name, state.description))
23        .collect();
24    exts.sort_by(|(a, _), (b, _)| a.cmp(b));
25    Ok(exts)
26}
27
28#[cfg(test)]
29pub(crate) mod test_util {
30    /// Serialize all tests that mutate process-wide environment variables.
31    /// Shared across modules to prevent cross-module races in `env::set_var`.
32    pub(crate) static ENV_MUTEX: std::sync::Mutex<()> = std::sync::Mutex::new(());
33}