From 108bc6f0446c351b421ba62367e0f4eaf6c62461 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sat, 24 Jan 2026 22:33:30 +0100 Subject: words: delete all relationships on 'rm' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When removing a word, all relationships with other words and tags should also be cleared. Not that it would litter too much the database (considering the DB is relatively small), but it doesn't take too much effort to play nice here. Signed-off-by: Miquel Sabaté Solà --- crates/cli/src/words.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'crates/cli') diff --git a/crates/cli/src/words.rs b/crates/cli/src/words.rs index a54e679..1567612 100644 --- a/crates/cli/src/words.rs +++ b/crates/cli/src/words.rs @@ -1010,6 +1010,15 @@ fn rm(mut args: IntoIter) -> i32 { } }; + // Fetch the word object for it which will serve as the initial values. + let word = match mihi::find_by(selection.as_str()) { + Ok(word) => word, + Err(e) => { + println!("error: words: {e}"); + return 1; + } + }; + let ans = Confirm::new( format!("Do you really want to remove '{selection}' from the database?").as_str(), ) @@ -1017,7 +1026,7 @@ fn rm(mut args: IntoIter) -> i32 { .prompt(); match ans { - Ok(true) => match mihi::delete_word(&selection) { + Ok(true) => match mihi::delete_word(&word) { Ok(_) => println!("Removed '{selection}' from the database!"), Err(e) => { println!("error: words: {e}"); -- cgit v1.2.3