feat: add argument validation for delete mode

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-29 14:28:57 -03:00
parent 6f05851282
commit 4472f3db94

View File

@@ -162,3 +162,24 @@ impl FromStr for NumberOrString {
} }
} }
impl Args {
/// Validate the arguments based on the selected mode
pub fn validate(&self) -> Result<(), String> {
// Check if --delete is used and ids_or_tags is empty
if self.mode.delete && self.ids_or_tags.is_empty() {
return Err("At least one ID is required when using --delete".to_string());
}
// Check if --delete is used and any of the ids_or_tags are tags (strings)
if self.mode.delete {
for item in &self.ids_or_tags {
if let NumberOrString::Str(_) = item {
return Err("Tags are not supported for --delete, only IDs".to_string());
}
}
}
Ok(())
}
}