use crate::cli::GlobalFlags;
use clap::Args;
#[derive(Args, Debug)]
pub struct RmArgs {
#[arg(short, long)]
pub force: bool,
#[arg(required = true, num_args = 1..)]
pub ids: Vec<String>,
}
pub async fn run(args: RmArgs, global: &GlobalFlags) -> anyhow::Result<()> {
let rt = global.create_runtime()?;
let handle = rt.volumes()?;
let mut had_error = false;
for id in &args.ids {
match handle.remove(id, args.force).await {
Ok(()) => println!("{id}"),
Err(e) => {
eprintln!("Error removing volume '{id}': {e}");
had_error = true;
}
}
}
if had_error {
anyhow::bail!("Some volumes could not be removed");
}
Ok(())
}