Continue actions refactoring
This commit is contained in:
parent
8726a1c6bf
commit
eb53590049
10 changed files with 162 additions and 38 deletions
|
@ -1,9 +1,12 @@
|
|||
use crate::{
|
||||
actions::{
|
||||
action::Action,
|
||||
confirm::{Confirm, ConfirmResult},
|
||||
},
|
||||
context::Context,
|
||||
utils::assets::{fetch_all_assets, AssetQuery},
|
||||
};
|
||||
use color_eyre::eyre::Result;
|
||||
use dialoguer::{theme::ColorfulTheme, Confirm};
|
||||
use log::info;
|
||||
use uuid::Uuid;
|
||||
|
||||
|
@ -22,15 +25,7 @@ pub async fn delete_assets(ctx: Context, offline: bool) -> Result<()> {
|
|||
);
|
||||
}
|
||||
|
||||
if !ctx.dry_run {
|
||||
if !(ctx.no_confirm
|
||||
|| Confirm::with_theme(&ColorfulTheme::default())
|
||||
.with_prompt("Do you want to continue?")
|
||||
.interact()?)
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let ConfirmResult::Positive = Confirm::new(None).execute(&ctx).await? {
|
||||
let asset_ids: Result<Vec<_>, uuid::Error> = assets
|
||||
.iter()
|
||||
.map(|asset| Uuid::parse_str(&asset.id))
|
||||
|
@ -41,13 +36,13 @@ pub async fn delete_assets(ctx: Context, offline: bool) -> Result<()> {
|
|||
ids: asset_ids?,
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
|
||||
info!(
|
||||
"Deleted {} assets{}",
|
||||
assets.len(),
|
||||
if ctx.dry_run { " (dry run)" } else { "" }
|
||||
);
|
||||
info!(
|
||||
"Deleted {} assets{}",
|
||||
assets.len(),
|
||||
if ctx.dry_run { " (dry run)" } else { "" }
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue