jensmemesclient/cli/src/commands/cats.rs
LordMZTE df7d39971b
All checks were successful
continuous-integration/drone/push Build is passing
client is now not static anymore
2021-05-27 18:01:30 +02:00

19 lines
480 B
Rust

use crate::table::{self, AsTableRow};
use jm_client_core::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(())
}