jensmemesclient/cli/src/commands/cats.rs

20 lines
491 B
Rust
Raw Normal View History

use crate::table::{self, IntoTableRow};
2021-04-01 19:12:23 +02:00
use jm_client_core::util::api;
use reqwest::Client;
pub async fn run(http: &Client) -> anyhow::Result<()> {
// clone required, because for sorting the immutable reference will not work
let mut cats = api::cats(http).await?.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.into_table_row());
}
println!("{}", table.render());
Ok(())
}