All checks were successful
Build and test / Build AMD64 (pull_request) Successful in 1m16s
Build and test / Tests (pull_request) Successful in 1m25s
Checking Renovate configuration / validate (pull_request) Successful in 1m55s
Checking yaml / Run yamllint (pull_request) Successful in 36s
Build and test / Clippy (pull_request) Successful in 31s
Build and test / Generate Documentation (pull_request) Successful in 55s
38 lines
1 KiB
Rust
38 lines
1 KiB
Rust
use crate::{
|
|
actions::{
|
|
action::Action, fetch_album_assets::FetchAlbumAssets, fetch_all_albums::FetchAllAlbums,
|
|
},
|
|
context::Context,
|
|
};
|
|
use color_eyre::eyre::{eyre, Result};
|
|
use tabled::{settings::Style, Table, Tabled};
|
|
|
|
#[derive(Tabled)]
|
|
struct AssetRow {
|
|
#[tabled(rename = "Path")]
|
|
original_file_path: String,
|
|
}
|
|
|
|
pub async fn list_album_assets(ctx: Context, album_name: &str) -> Result<()> {
|
|
let albums = FetchAllAlbums::new(()).execute(&ctx).await?;
|
|
|
|
let album = albums
|
|
.into_iter()
|
|
.find(|a| a.name == album_name)
|
|
.ok_or_else(|| eyre!("Album not found: {}", album_name))?;
|
|
|
|
let mut assets: Vec<_> = FetchAlbumAssets::new(album)
|
|
.execute(&ctx)
|
|
.await?
|
|
.into_iter()
|
|
.map(|asset| AssetRow {
|
|
original_file_path: asset.original_path.to_string_lossy().to_string(),
|
|
})
|
|
.collect();
|
|
|
|
assets.sort_by_key(|row| row.original_file_path.clone());
|
|
|
|
println!("{}", Table::new(assets).with(Style::rounded()));
|
|
|
|
Ok(())
|
|
}
|