fix: make id mandatory for delete and optional for get/info
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -25,16 +25,21 @@ pub fn mode_info(
|
||||
data_path: PathBuf,
|
||||
) -> Result<()> {
|
||||
// For --info, we only use IDs, tags should be empty
|
||||
if ids.is_empty() {
|
||||
cmd.error(ErrorKind::InvalidValue, "No ID provided for --info").exit();
|
||||
if ids.is_empty() && !_tags.is_empty() {
|
||||
cmd.error(ErrorKind::InvalidValue, "Tags are not supported for --info, only IDs").exit();
|
||||
} else if ids.len() > 1 {
|
||||
cmd.error(ErrorKind::InvalidValue, "More than one ID given, you must supply exactly one ID when using --info").exit();
|
||||
} else if ids.is_empty() {
|
||||
// If no ID is provided, find the last item
|
||||
// This matches the behavior in find_item when (true, true)
|
||||
// Clear the ids vector to ensure find_item uses the last item
|
||||
ids.clear();
|
||||
}
|
||||
|
||||
let item_service = ItemService::new(data_path.clone());
|
||||
// Use empty tags vector since --info only works with IDs
|
||||
let item_with_meta = item_service
|
||||
.find_item(conn, ids, &Vec::new(), &std::collections::HashMap::new())
|
||||
.find_item(conn, ids, _tags, &std::collections::HashMap::new())
|
||||
.map_err(|e| anyhow!("Unable to find matching item in database: {}", e))?;
|
||||
|
||||
show_item(item_with_meta, settings, data_path)
|
||||
|
||||
Reference in New Issue
Block a user