pub mod cli;
pub mod collectors;
pub mod config;
pub mod error;
pub mod install;
pub mod render;
pub mod report;
pub mod update;
pub use collectors::{CollectMode, SystemInfo};
pub use config::Config;
pub use error::{AppError, Result};
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
#[cfg(windows)]
#[link(name = "shell32")]
extern "system" {
fn IsUserAnAdmin() -> i32;
}
pub fn is_elevated() -> bool {
#[cfg(unix)]
unsafe {
libc::geteuid() == 0
}
#[cfg(windows)]
unsafe {
IsUserAnAdmin() != 0
}
}
pub fn platform_has_elevated_data() -> bool {
cfg!(target_os = "linux") || cfg!(target_os = "windows")
}
pub fn format_bytes(bytes: u64) -> String {
const KB: u64 = 1024;
const MB: u64 = KB * 1024;
const GB: u64 = MB * 1024;
const TB: u64 = GB * 1024;
if bytes >= TB {
format!("{:.2} TB", bytes as f64 / TB as f64)
} else if bytes >= GB {
format!("{:.2} GB", bytes as f64 / GB as f64)
} else if bytes >= MB {
format!("{:.2} MB", bytes as f64 / MB as f64)
} else if bytes >= KB {
format!("{:.2} KB", bytes as f64 / KB as f64)
} else {
format!("{} B", bytes)
}
}
pub fn generate_report() -> Result<String> {
let info = SystemInfo::collect()?;
let config = Config::default();
Ok(report::generate(&info, &config))
}
pub fn generate_report_with_config(config: &Config) -> Result<String> {
let info = SystemInfo::collect()?;
Ok(report::generate(&info, config))
}