use bitrouter_mcp::actions::commands::{CommandSource, CommandsReport};
use crate::output::CliReport;
use crate::output::human::Human;
impl CliReport for CommandsReport {
fn render(&self, h: &mut Human<'_>) -> std::io::Result<()> {
for source in [
CommandSource::Bitrouter,
CommandSource::Config,
CommandSource::Agent,
] {
let rows: Vec<_> = self
.commands
.iter()
.filter(|row| row.source == source)
.collect();
if rows.is_empty() {
if source == CommandSource::Agent {
h.note(if self.received {
"This agent advertises no commands."
} else {
"This agent had not sent its command list yet."
})?;
}
continue;
}
h.line(&format!("{} · {}", heading(source), rows.len()))?;
for row in rows {
let hint = row
.hint
.as_ref()
.map(|hint| format!(" <{hint}>"))
.unwrap_or_default();
let mut line = format!(" /{}{hint} {}", row.name, row.description);
if let Some(reason) = &row.unavailable {
line.push_str(&format!(" — {reason}"));
}
if row.shadowed {
line.push_str(" — shadowed");
}
h.line(&line)?;
}
}
Ok(())
}
}
fn heading(source: CommandSource) -> &'static str {
match source {
CommandSource::Bitrouter => "bitrouter",
CommandSource::Config => "config",
CommandSource::Agent => "agent",
}
}