18 lines
480 B
Rust
18 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(())
|
|
}
|