diff --git a/src/archived.rs b/src/archived.rs index 5a83849..998ebb2 100644 --- a/src/archived.rs +++ b/src/archived.rs @@ -20,7 +20,7 @@ struct Archived { lines: Snapshot, highlight_style: ContentStyle, case_insensitive: bool, - retry_command: Option, + cmd: Option, } impl promkit::Finalizer for Archived { @@ -44,7 +44,7 @@ impl promkit::Renderer for Archived { event, &mut self.text_editor_snapshot, &mut self.lines, - self.retry_command.clone(), + self.cmd.clone(), ); if self .text_editor_snapshot @@ -91,7 +91,7 @@ pub fn run( lines: listbox::State, highlight_style: ContentStyle, case_insensitive: bool, - retry_command: Option, + cmd: Option, ) -> anyhow::Result<()> { Prompt { renderer: Archived { @@ -100,7 +100,7 @@ pub fn run( lines: Snapshot::new(lines), highlight_style, case_insensitive, - retry_command, + cmd, }, } .run() diff --git a/src/archived/keymap.rs b/src/archived/keymap.rs index 791ca38..830cd12 100644 --- a/src/archived/keymap.rs +++ b/src/archived/keymap.rs @@ -16,7 +16,7 @@ pub fn default( event: &Event, text_editor_snapshot: &mut Snapshot, logs_snapshot: &mut Snapshot, - retry_command: Option, + cmd: Option, ) -> anyhow::Result { let text_editor_state = text_editor_snapshot.after_mut(); let logs_state = logs_snapshot.after_mut(); @@ -28,7 +28,7 @@ pub fn default( kind: KeyEventKind::Press, state: KeyEventState::NONE, }) => { - if retry_command.is_some() { + if cmd.is_some() { // Exiting archive mode here allows // the caller to re-enter streaming mode, // as it is running in an infinite loop. diff --git a/src/main.rs b/src/main.rs index 3cf9b36..8ddbaeb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,7 +86,7 @@ pub struct Args { long_help = "This command is invoked initially and whenever a retry is triggered according to key mappings." )] - pub retry_command: Option, + pub cmd: Option, } impl Drop for Args { @@ -187,7 +187,7 @@ async fn main() -> anyhow::Result<()> { Duration::from_millis(args.render_interval_millis), args.queue_capacity, args.case_insensitive, - args.retry_command.clone(), + args.cmd.clone(), ) .await { @@ -222,7 +222,7 @@ async fn main() -> anyhow::Result<()> { }, highlight_style, args.case_insensitive, - args.retry_command.clone(), + args.cmd.clone(), )?; // Re-enable raw mode and hide the cursor again here diff --git a/src/sig.rs b/src/sig.rs index 1df9815..4081108 100644 --- a/src/sig.rs +++ b/src/sig.rs @@ -78,7 +78,7 @@ pub async fn run( render_interval: Duration, queue_capacity: usize, case_insensitive: bool, - retry_command: Option, + cmd: Option, ) -> anyhow::Result<(Signal, VecDeque)> { let keymap = ActiveKeySwitcher::new("default", keymap::default); let size = crossterm::terminal::size()?; @@ -96,10 +96,8 @@ pub async fn run( let canceler = CancellationToken::new(); let canceled = canceler.clone(); - let streaming = if let Some(retry_command) = retry_command.clone() { - tokio::spawn( - async move { cmd::execute(&retry_command, tx, retrieval_timeout, canceled).await }, - ) + let streaming = if let Some(cmd) = cmd.clone() { + tokio::spawn(async move { cmd::execute(&cmd, tx, retrieval_timeout, canceled).await }) } else { tokio::spawn(async move { stdin::streaming(tx, retrieval_timeout, canceled).await }) }; @@ -145,7 +143,7 @@ pub async fn run( loop { let event = event::read()?; let mut text_editor = shared_text_editor.write().await; - signal = keymap.get()(&event, &mut text_editor, retry_command.clone())?; + signal = keymap.get()(&event, &mut text_editor, cmd.clone())?; if signal == Signal::GotoArchived || signal == Signal::GotoStreaming { break; } diff --git a/src/sig/keymap.rs b/src/sig/keymap.rs index 7b70476..69b6078 100644 --- a/src/sig/keymap.rs +++ b/src/sig/keymap.rs @@ -8,7 +8,7 @@ use crate::Signal; pub fn default( event: &Event, state: &mut text_editor::State, - retry_command: Option, + cmd: Option, ) -> anyhow::Result { match event { Event::Key(KeyEvent { @@ -24,7 +24,7 @@ pub fn default( kind: KeyEventKind::Press, state: KeyEventState::NONE, }) => { - if retry_command.is_some() { + if cmd.is_some() { return Ok(Signal::GotoStreaming); } }