From ed2f68332cdf25255cfeab82addb162c58e39236 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 27 Sep 2026 17:53:53 +0200 Subject: [PATCH] change lib per param --- src/albentohandy | 10 +++------- src/man/albentohandy.1 | 8 +++++--- tests/albentohandy.bats | 40 +++++++++++++++++++++++++--------------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/albentohandy b/src/albentohandy index e9dc606..24f7fb7 100755 --- a/src/albentohandy +++ b/src/albentohandy @@ -16,11 +16,9 @@ useage() echo "SYNOPSIS" echo " albentohandy [-3fho] [-i ]" echo "OPTIONS" - echo " -3 convert to mp3" - echo " -f convert to flac with cover" echo " -h show this usage" echo " -i optional input list (default albumlist)" - echo " -o convert to opus" + echo " -l lib [vorbis|mp3|opus|flac|]" } check_programs() @@ -138,13 +136,11 @@ main() check_programs || return $? load_config || return $? - while getopts "3fhi:o" opt; do + while getopts "hi:l:" opt; do case "$opt" in - "3") lib="mp3.sh" ;; - "f") lib="flac.sh" ;; "h") useage && return 0 ;; "i") albumlist="$OPTARG" ;; - "o") lib="opus.sh" ;; + "l") lib="$OPTARG.sh" ;; *) errlog "unknown option" && useage && return 1 ;; esac done diff --git a/src/man/albentohandy.1 b/src/man/albentohandy.1 index f584552..abeaab2 100644 --- a/src/man/albentohandy.1 +++ b/src/man/albentohandy.1 @@ -9,10 +9,12 @@ albentohandy [-3fho] [-i ] .SH OPTIONS .P .EX --3 convert to mp3 --f convert to flac with cover" -h show this usage" -i optional input list (default albumlist) --o convert to opus" +-l lib [vorbis|mp3|opus|flac|] + you can add custom lib + is install deb under /usr/lib/albentohandy + (e.g. /usr/lib/albentohandy/custom.sh) + or add on source src/lib (e.g. src/lib/custom.sh) .EE .P \ No newline at end of file diff --git a/tests/albentohandy.bats b/tests/albentohandy.bats index 67a0f85..9ca4fda 100755 --- a/tests/albentohandy.bats +++ b/tests/albentohandy.bats @@ -113,6 +113,19 @@ teardown() { assert_line --index 0 "❌ ERROR: lib build/tests/lib1/vorbis.sh not found" } +# bats test_tags=albentohandy:load_library,albentohandy:options +@test "failed: lib vorbis.sh not found with param" { + load_config() { + : + } + LIB_PATH="build/tests/lib1" + + run main -l vorbis + + assert_failure + assert_line --index 0 "❌ ERROR: lib build/tests/lib1/vorbis.sh not found" +} + # bats test_tags=albentohandy:load_library,albentohandy:options @test "failed: lib mp3.sh not found" { load_config() { @@ -120,7 +133,7 @@ teardown() { } LIB_PATH="build/tests/lib" - run main -3 + run main -l mp3 assert_failure assert_line --index 0 "❌ ERROR: lib build/tests/lib/mp3.sh not found" @@ -133,7 +146,7 @@ teardown() { } LIB_PATH="build/tests/lib" - run main -f + run main -l flac assert_failure assert_line --index 0 "❌ ERROR: lib build/tests/lib/flac.sh not found" @@ -146,7 +159,7 @@ teardown() { } LIB_PATH="build/tests/lib" - run main -o + run main -l opus assert_failure assert_line --index 0 "❌ ERROR: lib build/tests/lib/opus.sh not found" @@ -499,7 +512,7 @@ teardown() { mkdir --parents "build/tests/output/Artist1" echo "testfile" > "build/tests/output/Artist1/file.flac" - run main -i "build/tests/albumlist" -f + run main -i "build/tests/albumlist" -l flac assert_success [ -f "build/tests/output/Artist1/file.flac" ] @@ -529,7 +542,7 @@ teardown() { return 1 } - run main -i "build/tests/albumlist" -f + run main -i "build/tests/albumlist" -l flac assert_failure assert_line --index 0 "❌ ERROR: could not cleanup flac" @@ -595,11 +608,10 @@ teardown() { assert_line --index 2 "SYNOPSIS" assert_line --index 3 " albentohandy [-3fho] [-i ]" assert_line --index 4 "OPTIONS" - assert_line --index 5 " -3 convert to mp3" - assert_line --index 6 " -f convert to flac with cover" - assert_line --index 7 " -h show this usage" - assert_line --index 8 " -i optional input list (default albumlist)" - assert_line --index 9 " -o convert to opus" + assert_line --index 5 " -h show this usage" + assert_line --index 6 " -i optional input list (default albumlist)" + assert_line --index 7 " -l lib [vorbis|mp3|opus|flac|]" + } # bats test_tags=albentohandy:usage @@ -617,9 +629,7 @@ teardown() { assert_line --index 4 "SYNOPSIS" assert_line --index 5 " albentohandy [-3fho] [-i ]" assert_line --index 6 "OPTIONS" - assert_line --index 7 " -3 convert to mp3" - assert_line --index 8 " -f convert to flac with cover" - assert_line --index 9 " -h show this usage" - assert_line --index 10 " -i optional input list (default albumlist)" - assert_line --index 11 " -o convert to opus" + assert_line --index 7 " -h show this usage" + assert_line --index 8 " -i optional input list (default albumlist)" + assert_line --index 9 " -l lib [vorbis|mp3|opus|flac|]" } \ No newline at end of file -- 2.47.3