Skip to content

Commit 75af043

Browse files
committed
fix: log debug outputs to stderr
Send informations like "Checking dependencies", "Playing Episode n", etc to stderr so it can be routed easily to /dev/null if needed. Clear screen using tput clear only if player_function is not dump or download so debug/download statuses are preserved.
1 parent c818631 commit 75af043

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ani-cli

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ play() {
357357
range=$(printf "%s\n" "$ep_list" | sed -nE "/^${start}\$/,/^${end}\$/p")
358358
[ -z "$range" ] && die "Invalid range!"
359359
for i in $range; do
360-
tput clear
360+
[ "$player_function" != "debug" ] && [ "$player_function" != "download" ] && tput clear
361361
ep_no=$i
362-
printf "\33[2K\r\033[1;34mPlaying episode %s...\033[0m\n" "$ep_no"
362+
printf "\33[2K\r\033[1;34mPlaying episode %s...\033[0m\n" "$ep_no" >&2
363363
[ "$i" = "$end" ] && unset range
364364
play_episode
365365
done
@@ -476,15 +476,15 @@ done
476476
[ "$use_external_menu" = "0" ] && multi_selection_flag="${ANI_CLI_MULTI_SELECTION:-"-m"}"
477477
[ "$use_external_menu" = "1" ] && multi_selection_flag="${ANI_CLI_MULTI_SELECTION:-"-multi-select"}"
478478
[ "$external_menu_normal_window" = "1" ] && external_menu_args="-normal-window"
479-
printf "\33[2K\r\033[1;34mChecking dependencies...\033[0m\n"
479+
printf "\33[2K\r\033[1;34mChecking dependencies...\033[0m\n" >&2
480480
dep_ch "curl" "sed" "grep" || true
481481
[ "$skip_intro" = 1 ] && (dep_ch "ani-skip" || true)
482482
dep_ch "fzf" || true
483483
case "$player_function" in
484484
debug) ;;
485485
download) dep_ch "ffmpeg" "aria2c" ;;
486-
android*) printf "\33[2K\rChecking of players on Android is disabled\n" ;;
487-
*iSH*) printf "\33[2K\rChecking of players on iOS is disabled\n" ;;
486+
android*) printf "\33[2K\rChecking of players on Android is disabled\n" >&2 ;;
487+
*iSH*) printf "\33[2K\rChecking of players on iOS is disabled\n" >&2 ;;
488488
flatpak_mpv) true ;; # handled out of band in where_mpv
489489
*) dep_ch "$player_function" ;;
490490
esac
@@ -532,9 +532,9 @@ esac
532532
[ "$skip_intro" = 1 ] && mal_id="$(ani-skip -q "${skip_title:-${title}}")"
533533

534534
# moves the cursor up one line and clears that line
535-
tput cuu1 && tput el
535+
[ "$player_function" != "debug" ] && [ "$player_function" != "download" ] && tput cuu1 && tput el
536536
# stores the position of cursor
537-
tput sc
537+
[ "$player_function" != "debug" ] && [ "$player_function" != "download" ] && tput sc
538538

539539
# playback & loop
540540
play

0 commit comments

Comments
 (0)