pub mod cache;
pub mod discovery;
pub mod exec;
pub mod pager;
pub mod parser;
pub mod security;
pub mod types;
pub use cache::JustRegistry;
pub use types::ExecuteOutput;
pub use types::ExecuteParams;
pub use types::SearchItem;
pub use types::SearchOutput;
pub use types::SearchParams;
use once_cell::sync::OnceCell;
static JUST_OK: OnceCell<bool> = OnceCell::new();
pub async fn ensure_just_available() -> Result<(), String> {
if JUST_OK.get().copied() == Some(true) {
return Ok(());
}
let out = tokio::process::Command::new("just")
.arg("--version")
.output()
.await
.map_err(|e| format!("Failed to run 'just --version': {e}. Is 'just' installed?"))?;
if !out.status.success() {
return Err("`just` CLI returned non-zero; please install/repair".into());
}
let _ = JUST_OK.set(true);
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn just_binary_check() {
let result = ensure_just_available().await;
if result.is_err() {
eprintln!("Skipping test: just binary not available");
return;
}
assert!(ensure_just_available().await.is_ok());
}
}