feat: handle numeric strings as IDs for get and info modes
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
54
src/main.rs
54
src/main.rs
@@ -57,47 +57,37 @@ fn main() -> Result<(), Error> {
|
|||||||
let ids = &mut Vec::new();
|
let ids = &mut Vec::new();
|
||||||
let tags = &mut Vec::new();
|
let tags = &mut Vec::new();
|
||||||
|
|
||||||
// For --info mode, treat all arguments as IDs
|
// For --info and --get modes, treat numeric strings as IDs
|
||||||
if args.mode.info {
|
for v in args.ids_or_tags.iter() {
|
||||||
for v in args.ids_or_tags.iter() {
|
debug!("MAIN: Parsed value: {:?}", v);
|
||||||
debug!("MAIN: Parsed value: {:?}", v);
|
match v.clone() {
|
||||||
match v.clone() {
|
NumberOrString::Number(num) => {
|
||||||
NumberOrString::Number(num) => {
|
debug!("MAIN: Adding to ids: {}", num);
|
||||||
debug!("MAIN: Adding to ids: {}", num);
|
ids.push(num)
|
||||||
ids.push(num)
|
},
|
||||||
},
|
NumberOrString::Str(str) => {
|
||||||
NumberOrString::Str(str) => {
|
// For --info and --get, try to parse strings as numbers to treat them as IDs
|
||||||
// Try to parse as number for --info
|
if (args.mode.info || args.mode.get) {
|
||||||
if let Ok(num) = str.parse::<i64>() {
|
if let Ok(num) = str.parse::<i64>() {
|
||||||
debug!("MAIN: Adding parsed string to ids: {}", num);
|
debug!("MAIN: Adding parsed string to ids: {}", num);
|
||||||
ids.push(num)
|
ids.push(num);
|
||||||
} else {
|
continue;
|
||||||
|
} else if args.mode.info {
|
||||||
|
// --info only accepts numeric IDs
|
||||||
cmd.error(
|
cmd.error(
|
||||||
ErrorKind::InvalidValue,
|
ErrorKind::InvalidValue,
|
||||||
format!("--info requires numeric IDs, found: '{}'", str)
|
format!("--info requires numeric IDs, found: '{}'", str)
|
||||||
).exit();
|
).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)]
|
#[derive(PartialEq, Debug)]
|
||||||
enum KeepModes {
|
enum KeepModes {
|
||||||
|
|||||||
Reference in New Issue
Block a user