add -w flag for custom widths

This commit is contained in:
2025-12-16 18:29:45 +01:00
parent 7300ba933c
commit 6432d37df3
3 changed files with 17 additions and 7 deletions

View File

@@ -21,6 +21,7 @@ show_help() {
echo "usage: $(basename "$0") [flags] [reference...]"
echo
echo " -l list books"
echo " -w <n> set custom terminal width"
echo " -W no line wrap"
echo " -F no footnotes"
echo " -g show only German (no Latin)"
@@ -64,6 +65,14 @@ while [ $# -gt 0 ]; do
# List all book names with their abbreviations
get_data allioli.tsv | awk -v cmd=list "$(get_data allioli.awk)"
exit
elif [ "$1" = "-w" ]; then
shift
if [ $# -eq 0 ] || [ -z "$1" ]; then
echo "error: -w requires a width argument" >&2
exit 1
fi
export ALLIOLI_MAX_WIDTH="$1"
shift
elif [ "$1" = "-W" ]; then
export ALLIOLI_NOLINEWRAP=1
shift
@@ -83,9 +92,11 @@ while [ $# -gt 0 ]; do
fi
done
cols=$(tput cols 2>/dev/null)
if [ $? -eq 0 ]; then
export ALLIOLI_MAX_WIDTH="$cols"
if [ -z "$ALLIOLI_MAX_WIDTH" ]; then
cols=$(tput cols 2>/dev/null)
if [ $? -eq 0 ]; then
export ALLIOLI_MAX_WIDTH="$cols"
fi
fi
if [ $# -eq 0 ]; then