From 38c7ccea4875afab4f3feee3cc5f1167c5a560df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Mon, 25 Aug 2025 12:41:46 +0200 Subject: [PATCH] improvement: only --load-local requires MUSICDIR to be set --- src/main.sh | 64 ++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/main.sh b/src/main.sh index 7e6bc92..7f58b7c 100755 --- a/src/main.sh +++ b/src/main.sh @@ -36,46 +36,44 @@ set -eu . "sh/local.sh" # Support of local music files -if [ "${MUSICDIR:-}" ]; then - if [ "${1:-}" = "--decorate" ]; then - [ ! "${2:-}" ] && err "You did not specify a directory." && exit 1 - [ ! -d "$2" ] && err "Path $2 does not point to a directory." && exit 1 - if ! decorate "$2"; then - err "Something went wrong. Are you're files tagged correctly?" - exit 1 - fi - exit 0 +if [ "${1:-}" = "--decorate" ]; then + [ ! "${2:-}" ] && err "You did not specify a directory." && exit 1 + [ ! -d "$2" ] && err "Path $2 does not point to a directory." && exit 1 + if ! decorate "$2"; then + err "Something went wrong. Are you're files tagged correctly?" + exit 1 fi + exit 0 +fi - if [ "${1:-}" = "--load-local" ]; then - load_local || err "Failed to load local data" - exit 0 - fi +if [ "$MUSICDIR" ] && [ "${1:-}" = "--load-local" ]; then + load_local || err "Failed to load local data" + exit 0 +fi - if [ "${1:-}" = "--list-releases" ]; then - list_releases - exit 0 - fi +if [ "${1:-}" = "--list-releases" ]; then + list_releases + exit 0 +fi - if [ "${1:-}" = "--list-releasegroups" ]; then - list_releasegroups - exit 0 - fi +if [ "${1:-}" = "--list-releasegroups" ]; then + list_releasegroups + exit 0 +fi - if [ "${1:-}" = "--list-artists" ]; then - list_artists - exit 0 - fi +if [ "${1:-}" = "--list-artists" ]; then + list_artists + exit 0 +fi - if [ "${1:-}" = "--play-release" ]; then - echo "Playing release $2" >>/tmp/foo - exit 0 - fi +if [ "${1:-}" = "--play-release" ]; then + echo "Playing release $2" >>/tmp/foo + exit 0 +fi - if [ "${1:-}" = "--play-recording" ]; then - echo "Playing recording $2" >>/tmp/foo - exit 0 - fi +if [ "${1:-}" = "--play-recording" ]; then + echo "Playing recording $2" >>/tmp/foo + exit 0 fi if [ "${1:-}" = "--internal-preview-artist" ]; then