jensmemesclient/cli/src/commands/cats.rs

19 lines
473 B
Rust

use crate::table::{self, AsTableRow};
use libjens::JMClient;
pub async fn run(client: &JMClient) -> anyhow::Result<()> {
// clone required, because for sorting the immutable reference will not work
let mut cats = client.get_cats().await?.as_ref().clone();
cats.sort_by(|a, b| a.id.cmp(&b.id));
let mut table = table::list_table();
for cat in &cats {
table.add_row(cat.as_table_row());
}
println!("{}", table.render());
Ok(())
}