add -W to disable line wrap

This commit is contained in:
Tim Cooper 2018-08-11 15:51:10 -03:00
parent 5ddd6fc525
commit aab4c098b6
3 changed files with 12 additions and 1 deletions

View File

@ -7,6 +7,7 @@ Read the Word of God from your terminal
usage: ./kjv [flags] <references...>
-l list books
-W no line wrap
-h show help
References types:

View File

@ -107,6 +107,11 @@ function parseref(ref, arr) {
}
function printverse(verse, word_count, characters_printed) {
if (ENVIRON["KJV_NOLINEWRAP"] != "" && ENVIRON["KJV_NOLINEWRAP"] != "0") {
printf("%s\n", verse)
return
}
word_count = split(verse, words, " ")
for (i = 1; i <= word_count; i++) {
if (characters_printed + length(words[i]) + (characters_printed > 0 ? 1 : 0) > 72) {

7
kjv.sh
View File

@ -21,6 +21,7 @@ show_help() {
echo "usage: $(basename "$0") [flags] <references...>"
echo
echo " -l list books"
echo " -W no line wrap"
echo " -h show help"
echo
echo " References types:"
@ -60,10 +61,14 @@ while [ $# -gt 0 ]; do
# List all book names with their abbreviations
get_data kjv.tsv | awk -v cmd=list "$(get_data kjv.awk)"
exit
elif [ "$1" = "-W" ]; then
export KJV_NOLINEWRAP=1
shift
elif [ "$1" = "-h" ] || [ "$isFlag" -eq 1 ]; then
show_help
else
break
fi
break
done
if [ $# -eq 0 ]; then