aboutsummaryrefslogtreecommitdiffstats
path: root/crates
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-07-15 07:15:46 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-07-15 07:16:12 +0200
commitd8000c8591a4886023aaf52b9298147c67449932 (patch)
treeaf9371400f8018016fbfd7b149a2f224bb4a7eaa /crates
parentfix(crates/yt): Add stuff that was missed (diff)
downloadyt-d8000c8591a4886023aaf52b9298147c67449932.zip
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.
Diffstat (limited to '')
-rw-r--r--crates/yt/src/select/cmds/mod.rs19
1 files changed, 18 insertions, 1 deletions
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 <https://www.gnu.org/licenses/gpl-3.0.txt>.
+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<i64>,
ops: &mut Operations<Operation>,
) -> Result<()> {
@@ -87,6 +91,7 @@ async fn handle_status_change(
shared: SharedSelectionCommandArgs,
line_number: Option<i64>,
new_status: VideoStatus,
+ is_single: bool,
ops: &mut Operations<Operation>,
) -> 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(())
}