]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add print usage by unknown command
authorBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 14:15:12 +0000 (16:15 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 14:18:22 +0000 (16:18 +0200)
src/albentohandy
tests/albentohandy.bats

index 787553c5e9eb38106cd5d84991ff379b0a66aa05..69f817161a8c7d8b4ee60eaafb512a2c5dd20b29 100755 (executable)
@@ -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
 
index 6c97421974d33d914b0883b9ae46e2ab6c6f824b..4e34abf6bb9bc69837a7991452369791be754593 100755 (executable)
@@ -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