jensmemesclient/cli/src/commands/cats.rs

20 lines
489 B
Rust

use crate::util::{self, IntoTableRow};
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 = util::list_table();
for cat in &cats {
table.add_row(cat.into_table_row());
}
println!("{}", table.render());
Ok(())
}