From 51e59dd3d5a03fe968bd4cdbbd5eb2969558453e Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 25 Sep 2026 16:15:12 +0200 Subject: [PATCH] add print usage by unknown command --- src/albentohandy | 2 +- tests/albentohandy.bats | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/albentohandy b/src/albentohandy index 787553c..69f8171 100755 --- a/src/albentohandy +++ b/src/albentohandy @@ -121,7 +121,7 @@ main() "h") useage && return 0 ;; "i") albumlist="$OPTARG" ;; "o") lib="opus.sh" ;; - *) errlog "unknown option" && return 1 ;; + *) errlog "unknown option" && useage && return 1 ;; esac done diff --git a/tests/albentohandy.bats b/tests/albentohandy.bats index 6c97421..4e34abf 100755 --- a/tests/albentohandy.bats +++ b/tests/albentohandy.bats @@ -355,4 +355,21 @@ teardown() { assert_line --index 6 " -f convert to flac with cover" assert_line --index 7 " -h show this usage" assert_line --index 8 " -o convert to opus" +} + +# bats test_tags=albentohandy:usage +@test "failure: print usage by unknown command" { + run main -x + + assert_failure + assert_line --index 1 "❌ ERROR: unknown option" + assert_line --index 2 "NAME" + assert_line --index 3 " albentohandy - convert flac to ogg, mp3, opus or flac from music collection" + assert_line --index 4 "SYNOPSIS" + assert_line --index 5 " albentohandy [-3fho]" + 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 " -o convert to opus" } \ No newline at end of file -- 2.47.3