From 22f19cf9f50ae4ce96b175366602b9a2816332a6 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 19 Jan 2026 21:49:45 +0100 Subject: words: add the poke subcommand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This subcommand allows the user to update the `updated_at` timestamp, which is quite relevant as this timestamp is used when selecting words. Signed-off-by: Miquel Sabaté Solà --- crates/cli/src/words.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'crates') diff --git a/crates/cli/src/words.rs b/crates/cli/src/words.rs index 413d193..db8280c 100644 --- a/crates/cli/src/words.rs +++ b/crates/cli/src/words.rs @@ -74,6 +74,7 @@ fn help(msg: Option<&str>) { println!(" create\t\tCreate a new word."); println!(" edit\t\t\tEdit information from a word."); println!(" ls\t\t\tList the words from the database."); + println!(" poke\t\t\tUpdate the timestamp for a word."); println!(" rm\t\t\tRemove a word from the database."); println!(" show\t\t\tShow information from a word."); } @@ -682,6 +683,29 @@ fn show_info(word: Word) -> Result<(), String> { Ok(()) } +fn poke(mut args: IntoIter) -> i32 { + if args.len() > 1 { + help(Some( + "error: words: only one argument. If it's an enunciate, wrap it in double quotes", + )); + return 1; + } + + let enunciated = match select_single_word(args.next()) { + Ok(word) => word, + Err(e) => { + println!("error: words: {e}."); + return 1; + } + }; + + if mihi::update_timestamp(enunciated.as_str()).is_ok() { + 0 + } else { + 1 + } +} + fn show(mut args: IntoIter) -> i32 { if args.len() > 1 { help(Some( @@ -776,6 +800,9 @@ pub fn run(args: Vec) { "ls" => { std::process::exit(ls(it)); } + "poke" => { + std::process::exit(poke(it)); + } "rm" => { std::process::exit(rm(it)); } -- cgit v1.2.3