feat: Add --filters option to --get and parse filters early

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-09-03 07:42:28 -03:00
parent 639f2d511d
commit 5afe2f6bc8
4 changed files with 43 additions and 20 deletions

View File

@@ -181,6 +181,23 @@ impl ItemService {
conn: &Connection,
id: i64,
filter: Option<String>,
) -> Result<(Box<dyn Read + Send>, String, bool), CoreError> {
// Convert filter string to FilterChain if provided
let filter_chain = if let Some(filter_str) = filter {
self.filter_service.create_filter_chain(Some(&filter_str))
.map_err(|e| CoreError::InvalidInput(format!("Failed to create filter chain: {}", e)))?
} else {
None
};
self.get_item_content_info_streaming_with_chain(conn, id, filter_chain)
}
pub fn get_item_content_info_streaming_with_chain(
&self,
conn: &Connection,
id: i64,
filter_chain: Option<filter_plugin::FilterChain>,
) -> Result<(Box<dyn Read + Send>, String, bool), CoreError> {
let item_with_meta = self.get_item(conn, id)?;
let item_id = item_with_meta.item.id.ok_or_else(|| CoreError::InvalidInput("Item missing ID".to_string()))?;
@@ -197,10 +214,6 @@ impl ItemService {
&item_with_meta.item.compression
)?;
// Create filter chain
let filter_chain = self.filter_service.create_filter_chain(filter.as_deref())
.map_err(|e| CoreError::InvalidInput(format!("Failed to create filter chain: {}", e)))?;
// Wrap the reader with filtering
let filtered_reader = Box::new(FilteringReader::new(reader, filter_chain));