feat: enforce numeric IDs for --info command
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
53
src/main.rs
53
src/main.rs
@@ -57,23 +57,48 @@ fn main() -> Result<(), Error> {
|
||||
let ids = &mut Vec::new();
|
||||
let tags = &mut Vec::new();
|
||||
|
||||
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)
|
||||
},
|
||||
// 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
|
||||
if let Ok(num) = str.parse::<i64>() {
|
||||
debug!("MAIN: Adding parsed string to ids: {}", num);
|
||||
ids.push(num)
|
||||
} else {
|
||||
cmd.error(
|
||||
ErrorKind::InvalidValue,
|
||||
format!("--info requires numeric IDs, found: '{}'", str)
|
||||
).exit();
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
} 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 {
|
||||
Unknown,
|
||||
|
||||
Reference in New Issue
Block a user