feat: handle numeric tags as ids for info mode
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
11
src/main.rs
11
src/main.rs
@@ -58,9 +58,16 @@ fn main() -> Result<(), Error> {
|
|||||||
let tags = &mut Vec::new();
|
let tags = &mut Vec::new();
|
||||||
|
|
||||||
for v in args.ids_or_tags.iter() {
|
for v in args.ids_or_tags.iter() {
|
||||||
|
debug!("MAIN: Parsed value: {:?}", v);
|
||||||
match v.clone() {
|
match v.clone() {
|
||||||
NumberOrString::Number(num) => ids.push(num),
|
NumberOrString::Number(num) => {
|
||||||
NumberOrString::Str(str) => tags.push(str),
|
debug!("MAIN: Adding to ids: {}", num);
|
||||||
|
ids.push(num)
|
||||||
|
},
|
||||||
|
NumberOrString::Str(str) => {
|
||||||
|
debug!("MAIN: Adding to tags: {}", str);
|
||||||
|
tags.push(str)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,33 @@ pub fn mode_info(
|
|||||||
conn: &mut rusqlite::Connection,
|
conn: &mut rusqlite::Connection,
|
||||||
data_path: PathBuf,
|
data_path: PathBuf,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
// Check if any tags can be parsed as numbers and treat them as IDs for --info
|
||||||
|
let mut numeric_tags = Vec::new();
|
||||||
|
let mut non_numeric_tags = Vec::new();
|
||||||
|
|
||||||
|
for tag in tags.iter() {
|
||||||
|
if let Ok(num) = tag.parse::<i64>() {
|
||||||
|
numeric_tags.push(num);
|
||||||
|
} else {
|
||||||
|
non_numeric_tags.push(tag.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have numeric tags and no IDs, use them as IDs
|
||||||
|
if ids.is_empty() && !numeric_tags.is_empty() {
|
||||||
|
// For --info, we can only handle one ID
|
||||||
|
if numeric_tags.len() > 1 {
|
||||||
|
cmd.error(ErrorKind::InvalidValue, "More than one ID given, you must supply exactly one ID or atleast one tag when using --info").exit();
|
||||||
|
}
|
||||||
|
// Move the numeric tag to ids
|
||||||
|
ids.push(numeric_tags[0]);
|
||||||
|
// Clear the tags since we're now using an ID
|
||||||
|
tags.clear();
|
||||||
|
} else {
|
||||||
|
// Use the original logic
|
||||||
|
*tags = non_numeric_tags;
|
||||||
|
}
|
||||||
|
|
||||||
if !ids.is_empty() && !tags.is_empty() {
|
if !ids.is_empty() && !tags.is_empty() {
|
||||||
cmd.error(ErrorKind::InvalidValue, "Both ID and tags given, you must supply exactly one ID or atleast one tag when using --info").exit();
|
cmd.error(ErrorKind::InvalidValue, "Both ID and tags given, you must supply exactly one ID or atleast one tag when using --info").exit();
|
||||||
} else if ids.len() > 1 {
|
} else if ids.len() > 1 {
|
||||||
|
|||||||
Reference in New Issue
Block a user