From d8000c8591a4886023aaf52b9298147c67449932 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Tue, 15 Jul 2025 07:15:46 +0200 Subject: feat(crates/yt/select): Print the currently processed line as progress This is especially useful when using the commands standalone (i.e., `yt select watch ...`), as that will now show you exactly what your command did to the video. --- crates/yt/src/select/cmds/mod.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/yt/src/select/cmds/mod.rs b/crates/yt/src/select/cmds/mod.rs index 332010a..1713233 100644 --- a/crates/yt/src/select/cmds/mod.rs +++ b/crates/yt/src/select/cmds/mod.rs @@ -9,7 +9,10 @@ // You should have received a copy of the License along with this program. // If not, see . +use std::io::{Write, stderr}; + use crate::{ + ansi_escape_codes, app::App, cli::{SelectCommand, SharedSelectionCommandArgs}, storage::db::{ @@ -20,11 +23,12 @@ use crate::{ use anyhow::{Context, Result, bail}; -mod add; +pub(crate) mod add; pub(crate) async fn handle_select_cmd( app: &App, cmd: SelectCommand, + video: &mut Video, line_number: Option, ops: &mut Operations, ) -> Result<()> { @@ -87,6 +91,7 @@ async fn handle_status_change( shared: SharedSelectionCommandArgs, line_number: Option, new_status: VideoStatus, + is_single: bool, ops: &mut Operations, ) -> Result<()> { let priority = compute_priority(line_number, shared.priority); @@ -103,6 +108,18 @@ async fn handle_status_change( video.set_playback_speed(playback_speed, ops); } + if !is_single { + ansi_escape_codes::clear_whole_line(); + ansi_escape_codes::move_to_col(1); + } + + eprint!("{}", &video.to_line_display(app, None).await?); + + if is_single { + eprintln!(); + } else { + stderr().flush()?; + } Ok(()) } -- cgit 1.4.1