Add command to delete albums
This commit is contained in:
parent
fb78298166
commit
e29b962423
7 changed files with 152 additions and 1 deletions
29
src/commands/delete_albums.rs
Normal file
29
src/commands/delete_albums.rs
Normal 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(())
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
pub mod delete_albums;
|
||||
pub mod delete_assets;
|
||||
pub mod list_albums;
|
||||
pub mod list_assets;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue