increase coverage

This commit is contained in:
2026-04-29 14:58:27 -05:00
parent 3fec74f772
commit 5ecfd07ad2
4 changed files with 75 additions and 27 deletions
+16 -5
View File
@@ -55,7 +55,7 @@ debug() {
"$@"
}
# only perform the command given if ${DRY_RUN} is enabled
# only perform the command given if ${DRY_RUN} is disabled
void() {
if [[ ${DRY_RUN} == true ]]; then
return 0
@@ -138,6 +138,8 @@ cache_command() {
}
create_tmp_dir() {
[[ -n "${TMPDIR:-}" ]] && return
TMPDIR="$(mktemp -d)" || return 1
readonly TMPDIR
trap 'rm -rf ${TMPDIR}' EXIT
@@ -263,18 +265,27 @@ set_lyric_file_name() {
echo "${file%.opus}.lrc"
}
is_valid_lrc() {
validate_lrc() {
local file="$1"
local valid=1
# file does not exist, is invalid
if [[ ! -f "${file}" ]]; then
return 1
fi
local valid=0
while read -r line; do
[[ "${#line}" -eq 0 ]] && continue
if [[ "${line}" != '['* ]]; then
if [[ "${line}" != '['* && "${line}" != '#'* ]]; then
valid=1
break
fi
valid=0
done <"${file}"
if [[ ${valid} -eq 1 ]]; then
debug echo_fail "${file} is not valid lrc file"
dry rm "${file}" || return 1
fi
return ${valid}
}
+1 -1
View File
@@ -10,7 +10,7 @@ OPTIONS:
-d, --dir process files in directory
-r, --recurse recursively process directory
-f, --file process one file
-n, --dry-run do not actually add synced lyrics,
-n, --dry-run do not add synced lyrics,
just show the files that would be processed
-e, --eval output bash functions that can be directly processed
by eval for use with testing this script.