jensmemesclient/cli/src/commands/cats.rs

19 lines
463 B
Rust
Raw Normal View History

use crate::util::{self, api, IntoTableRow};
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(())
}