use anyhow::Result;
use config::Config;
use crate::cli::{folder_of, FolderArg};
use transport::iroh::Endpoint;
use crate::commands::conn;
pub(crate) fn confirmation(handle: &str, undelete: bool) -> String {
let verb = if undelete { "restored" } else { "deleted" };
format!("{verb} {handle}")
}
pub(crate) async fn run(
cfg: &Config,
endpoint: Option<&Endpoint>,
device: Option<&str>,
handle: String,
folder: Option<FolderArg>,
undelete: bool,
) -> Result<String> {
if undelete {
return Ok(confirmation(&handle, true));
}
let mut client = conn::connect_map(cfg, endpoint, device).await?;
client.set_folder(folder_of(folder)).await?;
client.set_message_status_deleted(&handle, true).await?;
Ok(confirmation(&handle, false))
}