From fc3dec8ff9f0f08c5526d6c4d920cd7ea16468a9 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 25 Sep 2026 10:34:45 +0200 Subject: [PATCH] add input file option --- src/albentohandy | 6 +++--- tests/albentohandy.bats | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/albentohandy b/src/albentohandy index a5cc59b..9829bad 100755 --- a/src/albentohandy +++ b/src/albentohandy @@ -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 $? diff --git a/tests/albentohandy.bats b/tests/albentohandy.bats index f7524cf..a51f918 100755 --- a/tests/albentohandy.bats +++ b/tests/albentohandy.bats @@ -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 -- 2.47.3