use crate::reply::help::HelpRow;
use crate::reply::ops::OpRow;
use crate::reply::search::Found;
use super::parts::{brief, line, line_over, listing, quoted, when};
pub(super) fn ops(rows: &[OpRow]) -> String {
let painted = rows
.iter()
.map(|row| {
line(vec![
Some(row.ts.clone()),
Some(row.client.clone()),
Some(row.origin.clone()),
Some(row.standing.clone()),
when(row.failed, &format!("{} ({})", row.exit_label, row.exit)),
Some(brief(&row.argv)),
])
})
.collect();
listing("trail", painted, "the trail is empty")
}
pub(super) fn found(found: &Found) -> String {
let hits = found
.rows
.iter()
.map(|hit| {
line(vec![
Some(hit.subject()),
Some(hit.at_field()),
quoted(&hit.excerpt),
])
})
.collect();
line_over(
&listing(
&format!("found {:?}", found.needle),
hits,
"no match anywhere this engine can see",
),
when(
!found.unreadable.is_empty(),
&format!("unread: {}", found.unreadable.join(", ")),
),
)
}
pub(super) fn help(rows: &[HelpRow]) -> String {
let painted = rows
.iter()
.map(|row| line(vec![Some(row.usage.clone()), Some(row.summary.clone())]))
.collect();
listing("the engine's own words", painted, "this engine names no op")
}