feat(core): Expand filtering into pipeline supporting multiple text search modes.

Modes include: exact match, smart-case, and regular expressions.
This commit is contained in:
2026-03-13 22:55:47 -04:00
parent 6187b83f26
commit 6a4cc85285
10 changed files with 1352 additions and 10 deletions

View File

@@ -1,25 +1,27 @@
//! JSON-backed menu implementation. Wraps `Vec<Item>` with
//! fuzzy filtering via nucleo. This is the default backend
//! pipeline filtering. This is the default backend
//! for `ls | pikl` style usage.
use crate::filter::{Filter, FuzzyFilter};
use crate::filter::Filter;
use crate::item::Item;
use crate::model::traits::Menu;
use crate::pipeline::FilterPipeline;
/// A menu backed by a flat list of JSON items. Handles
/// filtering internally using the [`Filter`] trait (fuzzy
/// by default). The `label_key` controls which JSON key
/// is used for display labels on object items.
/// filtering internally using the [`FilterPipeline`] which
/// supports fuzzy, exact, regex, and `|`-chained queries.
/// The `label_key` controls which JSON key is used for
/// display labels on object items.
pub struct JsonMenu {
items: Vec<Item>,
label_key: String,
filter: Box<dyn Filter>,
filter: FilterPipeline,
}
impl JsonMenu {
/// Create a new JSON menu with the given items and label key.
pub fn new(items: Vec<Item>, label_key: String) -> Self {
let mut filter = Box::new(FuzzyFilter::new());
let mut filter = FilterPipeline::new();
for (i, item) in items.iter().enumerate() {
filter.push(i, item.label());
}