From 0139060bf21a66327c7ce2ef8fdab911ec560eef Mon Sep 17 00:00:00 2001 From: Jeffrey Serio <23226432+hyperreal64@users.noreply.github.com> Date: Fri, 31 May 2024 14:07:08 -0500 Subject: [PATCH] Use parallel --- qbth | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/qbth b/qbth index b6f05ae..4435080 100755 --- a/qbth +++ b/qbth @@ -19,16 +19,24 @@ fi function add_torrents() { torrents=("$@") - parallel qbt torrent add url ::: "${torrents[@]}" + if ! parallel qbt torrent add url ::: "${torrents[@]}"; then + gum log -l error "Error adding torrents" + exit 1 + fi + for url in "${torrents[@]}"; do gum log -l info "Added" "$(basename $url)"; done } function delete_torrents() { if test -n "$1"; then - echo "$1" | parallel "qbt torrent delete --with-files {}" - echo "$1" | xargs -I _ gum log -l info "Deleted" _ + if ! "$(echo "$1" | parallel "qbt torrent delete --with-files {}")"; then + gum log -l error "Error deleting torrents" + exit 1 + else + echo "$1" | xargs -I _ gum log -l info "Deleted" _ + fi else - gum log -l info "Nothing to do." + gum log -l warn "Nothing to do." fi }