Files
keep/src/modes/delete.rs
Andrew Phillips fbdcb94ba1 fix: remove unused imports and parameters
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
2025-08-29 14:31:27 -03:00

40 lines
1.1 KiB
Rust

use anyhow::Result;
use std::path::PathBuf;
use crate::config;
use crate::services::error::CoreError;
use crate::services::item_service::ItemService;
use clap::error::ErrorKind;
use clap::Command;
use log::warn;
use rusqlite::Connection;
pub fn mode_delete(
_cmd: &mut Command,
_settings: &config::Settings,
_config: &config::Settings,
ids: &mut Vec<i64>,
_tags: &mut Vec<String>,
conn: &mut Connection,
data_path: PathBuf,
) -> Result<()> {
// Validation is now handled at the argument parsing level
// So we can assume ids is not empty and tags is empty
let item_service = ItemService::new(data_path);
for item_id in ids.iter() {
match item_service.delete_item(conn, *item_id) {
Ok(_) => {}
Err(e) => match e {
CoreError::ItemNotFound(_) => {
warn!("Unable to find item {item_id} in database");
}
_ => return Err(anyhow::Error::from(e).context(format!("Failed to delete item {}", item_id))),
},
}
}
Ok(())
}