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:
21
src/args.rs
21
src/args.rs
@@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user