add dump mode

This commit is contained in:
2025-12-22 17:51:04 +01:00
parent d75a6313c0
commit 48f8783943

View File

@@ -27,6 +27,7 @@ show_help() {
echo " -g show only German (no Latin)" echo " -g show only German (no Latin)"
echo " -L show only Latin (no German)" echo " -L show only Latin (no German)"
echo " -j output as JSON" echo " -j output as JSON"
echo " -d dump entire Bible (no interactive mode)"
echo " -h show help" echo " -h show help"
echo echo
echo " Reference types:" echo " Reference types:"
@@ -89,6 +90,9 @@ while [ $# -gt 0 ]; do
elif [ "$1" = "-j" ]; then elif [ "$1" = "-j" ]; then
export ALLIOLI_JSON_OUTPUT=1 export ALLIOLI_JSON_OUTPUT=1
shift shift
elif [ "$1" = "-d" ] || [ "$1" = "--dump" ]; then
export ALLIOLI_DUMP=1
shift
elif [ "$1" = "-h" ] || [ "$isFlag" -eq 1 ]; then elif [ "$1" = "-h" ] || [ "$isFlag" -eq 1 ]; then
show_help show_help
else else
@@ -104,6 +108,12 @@ if [ -z "$ALLIOLI_MAX_WIDTH" ]; then
fi fi
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
# If dump mode is enabled, dump everything instead of entering interactive mode
if [ -n "$ALLIOLI_DUMP" ] && [ "$ALLIOLI_DUMP" != "0" ]; then
get_data allioli.tsv | awk -v cmd=dump "$(get_data allioli.awk)"
exit 0
fi
if [ ! -t 0 ]; then if [ ! -t 0 ]; then
show_help show_help
fi fi
@@ -114,9 +124,19 @@ if [ $# -eq 0 ]; then
if ! read -r ref; then if ! read -r ref; then
break break
fi fi
# Use pager unless JSON output is enabled
if [ -n "$ALLIOLI_JSON_OUTPUT" ] && [ "$ALLIOLI_JSON_OUTPUT" != "0" ]; then
get_data allioli.tsv | awk -v cmd=ref -v ref="$ref" "$(get_data allioli.awk)"
else
get_data allioli.tsv | awk -v cmd=ref -v ref="$ref" "$(get_data allioli.awk)" | ${PAGER} get_data allioli.tsv | awk -v cmd=ref -v ref="$ref" "$(get_data allioli.awk)" | ${PAGER}
fi
done done
exit 0 exit 0
fi fi
get_data allioli.tsv | awk -v cmd=ref -v ref="$*" "$(get_data allioli.awk)" | ${PAGER} # Use pager unless JSON output or dump mode is enabled
if [ -n "$ALLIOLI_JSON_OUTPUT" ] && [ "$ALLIOLI_JSON_OUTPUT" != "0" ]; then
get_data allioli.tsv | awk -v cmd=ref -v ref="$*" "$(get_data allioli.awk)"
else
get_data allioli.tsv | awk -v cmd=ref -v ref="$*" "$(get_data allioli.awk)" | ${PAGER}
fi