jensmemesclient/cli/src/commands/cats.rs
LordMZTE bb33d3b015
All checks were successful
continuous-integration/drone/push Build is passing
category list improvements and cleanups
2021-01-05 15:13:19 +01:00

18 lines
463 B
Rust

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(())
}