improved options

This commit is contained in:
2025-08-25 13:26:41 +02:00
parent 7826cb471c
commit dd1b15e925

View File

@@ -396,7 +396,19 @@ fi
if [ "${1:-}" = "--help" ]; then if [ "${1:-}" = "--help" ]; then
cat <<EOF cat <<EOF
Usage: $0 [ --help | --artist <mbid> | --releasegroup <mbid> | --release <mbid> ] Usage: $0 [OPTION]
OPTIONS:
--help Show this help and exit.
--artist <mbid> List releasegroups of given artist <mbid>
--releasegroup <mbid> List releases in given release group <mbid>
--release <mbid> Show release given by <mbid>
--search-artist [<query>] Search artist
--search-album [<query>] Search album
--ni-search-artist [<query>] Non-interactive search
--ni-search-album [<query>] Non-interactive search
--decorate <path> Decorate directory containing a tagged release
--load-local Populate database with local music
EOF EOF
exit 0 exit 0
fi fi
@@ -412,18 +424,18 @@ PIDFILE="$tmpdir/pid"
trap 'rm -rf "$tmpdir"' EXIT INT trap 'rm -rf "$tmpdir"' EXIT INT
export LOCKFILE RESULTS PIDFILE export LOCKFILE RESULTS PIDFILE
if [ "${1:-}" = "--search-artist" ]; then if [ "${1:-}" = "--ni-search-artist" ]; then
$0 --internal-search "artist" "$2" $0 --internal-search "artist" "$2"
exit 0 exit 0
fi fi
if [ "${1:-}" = "--search-album" ]; then if [ "${1:-}" = "--ni-search-album" ]; then
$0 --internal-search "releasegroup" "$2" $0 --internal-search "releasegroup" "$2"
exit 0 exit 0
fi fi
case "${1:-}" in case "${1:-}" in
"" | "--artist" | "--releasegroup" | "--release") ;; "" | "--artist" | "--releasegroup" | "--release" | "--search-artist" | "--search-album") ;;
*) *)
err "Unknown option $1" err "Unknown option $1"
exit 1 exit 1
@@ -552,7 +564,7 @@ while true; do
) )
[ "$sel" ] && set -- "--artist" "$sel" [ "$sel" ] && set -- "--artist" "$sel"
;; ;;
"--search-releasegroup") "--search-album")
sel=$( sel=$(
printf "" | printf "" |
$FZF \ $FZF \
@@ -569,6 +581,7 @@ while true; do
--accept-nth="{2}" \ --accept-nth="{2}" \
--with-nth="{1}" \ --with-nth="{1}" \
--expect="ctrl-c,ctrl-q,tab" \ --expect="ctrl-c,ctrl-q,tab" \
--bind="start:transform:[ \"${2:-}\" ] && echo \"change-query:${2:-}\"" \
--bind="load:unbind(enter)+transform:[ \"\$FZF_TOTAL_COUNT\" -gt 0 ] && echo \"rebind:ctrl-l\" || echo \"unbind:ctrl-l\"" \ --bind="load:unbind(enter)+transform:[ \"\$FZF_TOTAL_COUNT\" -gt 0 ] && echo \"rebind:ctrl-l\" || echo \"unbind:ctrl-l\"" \
--bind="ctrl-l:accept" \ --bind="ctrl-l:accept" \
--bind="ctrl-d:half-page-down,ctrl-u:half-page-up" \ --bind="ctrl-d:half-page-down,ctrl-u:half-page-up" \
@@ -583,7 +596,7 @@ while true; do
[ "$key" = "tab" ] && set -- "--search-artist" [ "$key" = "tab" ] && set -- "--search-artist"
[ "$lns" -eq 2 ] && [ ! "$key" ] && [ "$mid" ] && set -- "--releasegroup" "$mid" [ "$lns" -eq 2 ] && [ ! "$key" ] && [ "$mid" ] && set -- "--releasegroup" "$mid"
;; ;;
*) "--search-artist")
sel=$( sel=$(
printf "" | printf "" |
$FZF \ $FZF \
@@ -602,6 +615,7 @@ while true; do
--preview-window="right,25%,border-left,wrap,<30(hidden)" \ --preview-window="right,25%,border-left,wrap,<30(hidden)" \
--preview="$0 --internal-preview-artist {2}" \ --preview="$0 --internal-preview-artist {2}" \
--expect="ctrl-c,ctrl-q,tab" \ --expect="ctrl-c,ctrl-q,tab" \
--bind="start:transform:[ \"${2:-}\" ] && echo \"change-query:${2:-}\"" \
--bind="load:unbind(enter)+transform:[ \"\$FZF_TOTAL_COUNT\" -gt 0 ] && echo \"rebind:ctrl-l\" || echo \"unbind:ctrl-l\"" \ --bind="load:unbind(enter)+transform:[ \"\$FZF_TOTAL_COUNT\" -gt 0 ] && echo \"rebind:ctrl-l\" || echo \"unbind:ctrl-l\"" \
--bind="ctrl-l:accept" \ --bind="ctrl-l:accept" \
--bind="ctrl-d:half-page-down,ctrl-u:half-page-up" \ --bind="ctrl-d:half-page-down,ctrl-u:half-page-up" \
@@ -614,8 +628,11 @@ while true; do
mid=$(echo "$sel" | head -2 | tail -1) mid=$(echo "$sel" | head -2 | tail -1)
[ "$key" = "ctrl-c" ] && tput rmcup && exit 0 [ "$key" = "ctrl-c" ] && tput rmcup && exit 0
[ "$key" = "ctrl-q" ] && tput rmcup && exit 0 [ "$key" = "ctrl-q" ] && tput rmcup && exit 0
[ "$key" = "tab" ] && set -- "--search-releasegroup" [ "$key" = "tab" ] && set -- "--search-album"
[ "$lns" -eq 2 ] && [ ! "$key" ] && [ "$mid" ] && set -- "--artist" "$mid" [ "$lns" -eq 2 ] && [ ! "$key" ] && [ "$mid" ] && set -- "--artist" "$mid"
;; ;;
*)
set -- "--search-artist"
;;
esac esac
done done