use owo_colors::OwoColorize;
use crate::config::{Config, NodeConfig};
pub fn list_clusters(config: &Config) {
if config.clusters.is_empty() {
println!("{}", "No clusters configured".dimmed());
return;
}
println!("\n{} {}\n", "▶".cyan(), "Available clusters".bold());
for (name, cluster) in &config.clusters {
println!(
" {} {} ({} {})",
"●".blue(),
name.bold(),
cluster.nodes.len().to_string().yellow(),
if cluster.nodes.len() == 1 {
"node"
} else {
"nodes"
}
);
for node_config in &cluster.nodes {
let node_str = match node_config {
NodeConfig::Simple(s) => s.clone(),
NodeConfig::Detailed { host, .. } => host.clone(),
};
println!(" {} {}", "•".dimmed(), node_str.dimmed());
}
}
println!();
}