From e9f591d2c493fd9da51f6d71c2d559640fb79fd6 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Fri, 29 Aug 2025 12:45:01 -0300 Subject: [PATCH] feat: handle numeric strings as IDs for get and info modes Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) --- src/main.rs | 54 ++++++++++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2d1d3fe..500fec7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,47 +57,37 @@ fn main() -> Result<(), Error> { let ids = &mut Vec::new(); let tags = &mut Vec::new(); - // For --info mode, treat all arguments as IDs - if args.mode.info { - for v in args.ids_or_tags.iter() { - debug!("MAIN: Parsed value: {:?}", v); - match v.clone() { - NumberOrString::Number(num) => { - debug!("MAIN: Adding to ids: {}", num); - ids.push(num) - }, - NumberOrString::Str(str) => { - // Try to parse as number for --info + // For --info and --get modes, treat numeric strings as IDs + for v in args.ids_or_tags.iter() { + debug!("MAIN: Parsed value: {:?}", v); + match v.clone() { + NumberOrString::Number(num) => { + debug!("MAIN: Adding to ids: {}", num); + ids.push(num) + }, + NumberOrString::Str(str) => { + // For --info and --get, try to parse strings as numbers to treat them as IDs + if (args.mode.info || args.mode.get) { if let Ok(num) = str.parse::() { debug!("MAIN: Adding parsed string to ids: {}", num); - ids.push(num) - } else { + ids.push(num); + continue; + } else if args.mode.info { + // --info only accepts numeric IDs cmd.error( ErrorKind::InvalidValue, format!("--info requires numeric IDs, found: '{}'", str) ).exit(); } - }, - } + } + // If not a number, or not using --info/--get, treat as tag + debug!("MAIN: Adding to tags: {}", str); + tags.push(str) + }, } - } else { - // Original logic for other modes - for v in args.ids_or_tags.iter() { - debug!("MAIN: Parsed value: {:?}", v); - match v.clone() { - NumberOrString::Number(num) => { - debug!("MAIN: Adding to ids: {}", num); - ids.push(num) - }, - NumberOrString::Str(str) => { - debug!("MAIN: Adding to tags: {}", str); - tags.push(str) - }, - } - } - tags.sort(); - tags.dedup(); } + tags.sort(); + tags.dedup(); #[derive(PartialEq, Debug)] enum KeepModes {