diff --git a/Cargo.lock b/Cargo.lock index bd46529..961e4bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1224,7 +1224,7 @@ checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" dependencies = [ "getrandom", "libredox", - "thiserror 2.0.11", + "thiserror 2.0.12", ] [[package]] @@ -1424,11 +1424,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.11", + "thiserror-impl 2.0.12", ] [[package]] @@ -1444,9 +1444,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", diff --git a/src/main.rs b/src/main.rs index 2832689..4d4c9d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use crossterm::style::Attribute; use promkit::{ jsonz::format::RowFormatter, listbox::{self, Listbox}, - text_editor, + text_editor::{self, TextEditor}, }; mod editor; @@ -64,6 +64,16 @@ pub struct Args { #[arg(short = 'c', long = "config", help = "Path to the configuration file.")] pub config_file: Option, + + #[arg( + long = "default-filter", + help = "Default jq filter to apply to the input data", + long_help = " + Sets the default jq filter to apply to the input data. + The filter is applied when the interface is first loaded. + " + )] + default_filter: Option, } /// Parses the input based on the provided arguments. @@ -163,7 +173,11 @@ async fn main() -> anyhow::Result<()> { IncrementalSearcher::new(listbox_state, config.completion.search_result_chunk_size); let text_editor_state = text_editor::State { - texteditor: Default::default(), + texteditor: if let Some(filter) = args.default_filter { + TextEditor::new(filter) + } else { + Default::default() + }, history: Default::default(), prefix: config.editor.theme_on_focus.prefix.clone(), mask: Default::default(), diff --git a/src/prompt.rs b/src/prompt.rs index 6ac7ba6..33fd176 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -117,6 +117,9 @@ pub async fn run( last_query_tx, reactivity_control.query_debounce_duration, ); + if !editor.text().is_empty() { + debounce_query_tx.send(editor.text()).await?; + } let (last_resize_tx, mut last_resize_rx) = mpsc::channel::<(u16, u16)>(1); let (debounce_resize_tx, debounce_resize_rx) = mpsc::channel(1);