]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add input file option
authorBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 08:34:45 +0000 (10:34 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 08:38:03 +0000 (10:38 +0200)
src/albentohandy
tests/albentohandy.bats

index a5cc59b24dcbfd001727ac74f5f075f1ac83c133..9829bad988689e33d9253db4084973e8172c270b 100755 (executable)
@@ -36,15 +36,16 @@ load_config()
 
 main()
 {
-       local albumlist=${albumlist:-"albumlist"}
+       local albumlist="albumlist"
        local lib="vorbis.sh"
        check_programs || return $?
        load_config || return $?
 
-       while getopts "3fo" opt; do
+       while getopts "3fi:o" opt; do
                case "$opt" in
                "3") lib="mp3.sh" ;;
                "f") lib="flac.sh" ;;
+               "i") albumlist="$OPTARG" ;;
                "o") lib="opus.sh" ;;
                *) errlog "unknown option" && return 1 ;;
                esac
@@ -54,7 +55,6 @@ main()
                || errlog "lib $LIB_PATH/$lib not found" \
                || return $?
 
-
        [ -f "$albumlist" ] \
                || errlog "file $albumlist does not exists" \
                || return $?
index f7524cf5179bd14c8bae19bb47d7858ece4a467d..a51f918b4048703e0493d4e5108b39851c841eb2 100755 (executable)
@@ -95,4 +95,11 @@ teardown() {
 
        assert_failure
        assert_line --index 0 "❌ ERROR: file albumlist does not exists"
+}
+
+@test "failed: input file asdf not found" {
+       run main -i "asdf"
+
+       assert_failure
+       assert_line --index 0 "❌ ERROR: file asdf does not exists"
 }
\ No newline at end of file