add -w flag for custom widths
This commit is contained in:
@@ -10,6 +10,7 @@ Code largely based off of [https://github.com/bontibon/kjv.git](https://github.c
|
||||
usage: ./allioli [flags] [reference...]
|
||||
|
||||
-l list books
|
||||
-w <n> set custom terminal width
|
||||
-W no line wrap
|
||||
-F no footnotes
|
||||
-g show only German (no Latin)
|
||||
|
||||
@@ -7,12 +7,10 @@ BEGIN {
|
||||
# $6 Verse
|
||||
FS = "\t"
|
||||
|
||||
MAX_WIDTH = 100
|
||||
MAX_WIDTH = 120
|
||||
if (ENVIRON["ALLIOLI_MAX_WIDTH"] ~ /^[0-9]+$/) {
|
||||
if (int(ENVIRON["ALLIOLI_MAX_WIDTH"]) < MAX_WIDTH) {
|
||||
MAX_WIDTH = int(ENVIRON["ALLIOLI_MAX_WIDTH"])
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd == "ref") {
|
||||
mode = parseref(ref, p)
|
||||
|
||||
11
allioli.sh
11
allioli.sh
@@ -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,10 +92,12 @@ while [ $# -gt 0 ]; do
|
||||
fi
|
||||
done
|
||||
|
||||
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
|
||||
if [ ! -t 0 ]; then
|
||||
|
||||
Reference in New Issue
Block a user