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...]
|
usage: ./allioli [flags] [reference...]
|
||||||
|
|
||||||
-l list books
|
-l list books
|
||||||
|
-w <n> set custom terminal width
|
||||||
-W no line wrap
|
-W no line wrap
|
||||||
-F no footnotes
|
-F no footnotes
|
||||||
-g show only German (no Latin)
|
-g show only German (no Latin)
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ BEGIN {
|
|||||||
# $6 Verse
|
# $6 Verse
|
||||||
FS = "\t"
|
FS = "\t"
|
||||||
|
|
||||||
MAX_WIDTH = 100
|
MAX_WIDTH = 120
|
||||||
if (ENVIRON["ALLIOLI_MAX_WIDTH"] ~ /^[0-9]+$/) {
|
if (ENVIRON["ALLIOLI_MAX_WIDTH"] ~ /^[0-9]+$/) {
|
||||||
if (int(ENVIRON["ALLIOLI_MAX_WIDTH"]) < MAX_WIDTH) {
|
MAX_WIDTH = int(ENVIRON["ALLIOLI_MAX_WIDTH"])
|
||||||
MAX_WIDTH = int(ENVIRON["ALLIOLI_MAX_WIDTH"])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd == "ref") {
|
if (cmd == "ref") {
|
||||||
|
|||||||
17
allioli.sh
17
allioli.sh
@@ -21,6 +21,7 @@ show_help() {
|
|||||||
echo "usage: $(basename "$0") [flags] [reference...]"
|
echo "usage: $(basename "$0") [flags] [reference...]"
|
||||||
echo
|
echo
|
||||||
echo " -l list books"
|
echo " -l list books"
|
||||||
|
echo " -w <n> set custom terminal width"
|
||||||
echo " -W no line wrap"
|
echo " -W no line wrap"
|
||||||
echo " -F no footnotes"
|
echo " -F no footnotes"
|
||||||
echo " -g show only German (no Latin)"
|
echo " -g show only German (no Latin)"
|
||||||
@@ -64,6 +65,14 @@ while [ $# -gt 0 ]; do
|
|||||||
# List all book names with their abbreviations
|
# List all book names with their abbreviations
|
||||||
get_data allioli.tsv | awk -v cmd=list "$(get_data allioli.awk)"
|
get_data allioli.tsv | awk -v cmd=list "$(get_data allioli.awk)"
|
||||||
exit
|
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
|
elif [ "$1" = "-W" ]; then
|
||||||
export ALLIOLI_NOLINEWRAP=1
|
export ALLIOLI_NOLINEWRAP=1
|
||||||
shift
|
shift
|
||||||
@@ -83,9 +92,11 @@ while [ $# -gt 0 ]; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
cols=$(tput cols 2>/dev/null)
|
if [ -z "$ALLIOLI_MAX_WIDTH" ]; then
|
||||||
if [ $? -eq 0 ]; then
|
cols=$(tput cols 2>/dev/null)
|
||||||
export ALLIOLI_MAX_WIDTH="$cols"
|
if [ $? -eq 0 ]; then
|
||||||
|
export ALLIOLI_MAX_WIDTH="$cols"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user