set envvars

This commit is contained in:
Jana Dönszelmann 2026-02-20 12:40:07 +01:00
commit 3963fc50c3
No known key found for this signature in database
9 changed files with 3248 additions and 0 deletions

158
src/tui/filter.rs Normal file
View file

@ -0,0 +1,158 @@
use crate::tui::model::LogEntry;
pub enum WipMatcher {
Field {
name: Option<String>,
value: Option<serde_json::Value>,
},
Specific {
path: Option<Vec<usize>>,
},
}
impl WipMatcher {
fn validate(&self) -> Option<Matcher> {
match self {
WipMatcher::Field {
name: Some(name),
value: Some(value),
} => Some(Matcher::Field {
name: name.clone(),
value: value.clone(),
}),
WipMatcher::Specific { path: Some(path) } => {
Some(Matcher::Specific { path: path.clone() })
}
_ => None,
}
}
}
pub enum Matcher {
Field {
name: String,
value: serde_json::Value,
},
Specific {
path: Vec<usize>,
},
}
impl Matcher {
pub fn matches(&self, entry: &LogEntry) -> bool {
match self {
Matcher::Field { name, value } => entry
.all_fields()
.fields
.get(name)
.is_some_and(|v| v == value),
Matcher::Specific { path } => false,
}
}
}
#[derive(Clone)]
pub enum FilterKind {
Inline,
Remove,
}
pub struct Filter {
pub matcher: Matcher,
pub kind: FilterKind,
}
pub struct WipFilter {
pub matcher: Option<WipMatcher>,
pub kind: Option<FilterKind>,
pub selection: FilterSelection,
}
impl WipFilter {
pub fn validate(&self) -> Option<Filter> {
let Self {
matcher,
kind,
selection: _,
} = self;
let Some(matcher) = matcher else { return None };
Some(Filter {
matcher: matcher.validate()?,
kind: kind.clone()?,
})
}
pub fn clear(&mut self) {
match self.selection {
FilterSelection::Kind => self.kind = None,
FilterSelection::MatcherKind => {}
FilterSelection::Matcher => {}
FilterSelection::Confirm => {}
}
}
pub fn right(&mut self) {
match self.selection {
FilterSelection::Kind => {
self.kind = Some(match self.kind {
None => FilterKind::Inline,
Some(FilterKind::Inline) => FilterKind::Remove,
Some(FilterKind::Remove) => FilterKind::Inline,
})
}
FilterSelection::MatcherKind => {}
FilterSelection::Matcher => {}
FilterSelection::Confirm => {}
}
}
pub fn left(&mut self) {
match self.selection {
FilterSelection::Kind => {
self.kind = Some(match self.kind {
None => FilterKind::Remove,
Some(FilterKind::Remove) => FilterKind::Inline,
Some(FilterKind::Inline) => FilterKind::Inline,
})
}
FilterSelection::MatcherKind => {}
FilterSelection::Matcher => {}
FilterSelection::Confirm => {}
}
}
}
#[derive(Clone, Copy)]
pub enum FilterSelection {
Kind,
MatcherKind,
Matcher,
Confirm,
}
impl FilterSelection {
pub fn next(&mut self) {
*self = match *self {
Self::Kind => Self::MatcherKind,
Self::MatcherKind => Self::Matcher,
Self::Matcher => Self::Confirm,
Self::Confirm => Self::Confirm,
};
}
pub fn prev(&mut self) {
*self = match self {
Self::Kind => Self::Kind,
Self::MatcherKind => Self::Kind,
Self::Matcher => Self::MatcherKind,
Self::Confirm => Self::Matcher,
};
}
}
#[derive(Clone, Copy)]
pub enum FieldMatcherSelection {
Field,
Value,
}
impl FieldMatcherSelection {}