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:
@@ -4,6 +4,7 @@ use std::io::Write;
|
||||
use crate::common::is_binary::is_binary;
|
||||
use crate::common::PIPESIZE;
|
||||
use crate::config;
|
||||
use crate::filter_plugin::FilterChain;
|
||||
use crate::services::item_service::ItemService;
|
||||
use clap::Command;
|
||||
use is_terminal::IsTerminal;
|
||||
@@ -17,7 +18,7 @@ pub fn mode_get(
|
||||
tags: &mut Vec<String>,
|
||||
conn: &mut rusqlite::Connection,
|
||||
data_path: PathBuf,
|
||||
filters: &Vec<String>,
|
||||
filter_chain: Option<FilterChain>,
|
||||
) -> Result<()> {
|
||||
if !ids.is_empty() && !tags.is_empty() {
|
||||
cmd.error(clap::error::ErrorKind::InvalidValue, "Both ID and tags given, you must supply either IDs or tags when using --get").exit();
|
||||
@@ -48,18 +49,11 @@ pub fn mode_get(
|
||||
}
|
||||
}
|
||||
|
||||
// Join all filter strings with | to create a single filter string
|
||||
let filter_str = if filters.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(filters.join(" | "))
|
||||
};
|
||||
|
||||
// Get a reader that applies the filters
|
||||
let (mut reader, _, _) = item_service.get_item_content_info_streaming(
|
||||
// Get a reader that applies the filters using the pre-parsed filter chain
|
||||
let (mut reader, _, _) = item_service.get_item_content_info_streaming_with_chain(
|
||||
conn,
|
||||
item_id,
|
||||
filter_str.clone(),
|
||||
filter_chain,
|
||||
)?;
|
||||
|
||||
if detect_binary {
|
||||
@@ -72,10 +66,10 @@ pub fn mode_get(
|
||||
));
|
||||
}
|
||||
// We need to create a new reader since we consumed some bytes
|
||||
let (new_reader, _, _) = item_service.get_item_content_info_streaming(
|
||||
let (new_reader, _, _) = item_service.get_item_content_info_streaming_with_chain(
|
||||
conn,
|
||||
item_id,
|
||||
filter_str.clone(),
|
||||
filter_chain,
|
||||
)?;
|
||||
reader = new_reader;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user