Add command to delete albums

This commit is contained in:
Marc Plano-Lesay 2024-11-24 02:01:48 +01:00
parent fb78298166
commit e29b962423
Signed by: kernald
GPG key ID: 66A41B08CC62A6CF
7 changed files with 152 additions and 1 deletions

View file

@ -0,0 +1,29 @@
use crate::{
actions::{
action::Action,
confirm::{Confirm, ConfirmResult},
delete_album::DeleteAlbum,
fetch_all_albums::FetchAllAlbums,
},
context::Context,
};
use color_eyre::eyre::Result;
use log::info;
pub async fn delete_albums(ctx: Context) -> Result<()> {
let albums = FetchAllAlbums::new(()).execute(&ctx).await?;
if let ConfirmResult::Positive = Confirm::new(None).execute(&ctx).await? {
for album in &albums {
DeleteAlbum::new(album.clone()).execute(&ctx).await?;
}
info!(
"Deleted {} albums{}",
albums.len(),
if ctx.dry_run { " (dry run)" } else { "" }
);
}
Ok(())
}