use snafu::ResultExt;
use crate::{IoSnafu, TuiResult, utils};
pub fn show_info() -> TuiResult<()> {
println!("Wasmind Configuration and Cache Information");
println!("======================================");
let config_dir = wasmind::wasmind_config::get_config_dir()?;
println!("Config directory: {}", config_dir.display());
let config_file = wasmind::wasmind_config::get_config_file_path()?;
if config_file.exists() {
println!("Config file: {} (exists)", config_file.display());
} else {
println!("Config file: {} (not found)", config_file.display());
}
println!("Note: Use -c <PATH> to specify a custom config file");
let cache_dir = wasmind::wasmind_config::get_cache_dir()?;
println!("\nCache directory: {}", cache_dir.display());
let actors_cache_dir = wasmind::wasmind_config::get_actors_cache_dir()?;
let cached_count = utils::count_cached_actors(&actors_cache_dir).context(IoSnafu)?;
if cached_count > 0 {
println!(
"Actor cache: {} (contains {} cached actors)",
actors_cache_dir.display(),
cached_count
);
} else {
println!("Actor cache: {} (empty)", actors_cache_dir.display());
}
println!();
let log_file = wasmind::wasmind_config::get_log_file_path()?;
let current_log_level = std::env::var("WASMIND_LOG").unwrap_or_else(|_| "info".to_string());
if log_file.exists() {
println!("Log file: {} (exists)", log_file.display());
if let Ok(metadata) = std::fs::metadata(&log_file) {
println!("Log size: {} bytes", metadata.len());
}
} else {
println!("Log file: {} (not created yet)", log_file.display());
}
println!("Log level: {current_log_level}");
println!("Note: Use --log-file <PATH> to specify a custom log location");
println!(" Set WASMIND_LOG environment variable to change log level");
println!(" Examples: WASMIND_LOG=debug, WASMIND_LOG=trace, WASMIND_LOG=warn");
Ok(())
}