Add a font testing script
I had to delete my old commit because it had too many problems with the script.
This commit is contained in:
parent
fb9fd8d271
commit
7d13a4be94
|
@ -0,0 +1,80 @@
|
|||
#!/bin/sh
|
||||
|
||||
fontDir="/usr/share/figlet"
|
||||
toiletFlag=
|
||||
|
||||
help=$(
|
||||
cat << EOF
|
||||
Usage:
|
||||
$0 [-ht] [-d] [message]
|
||||
|
||||
OPTIONS
|
||||
-h display this help
|
||||
-t specify this option if you have toilet fonts aswell
|
||||
-d font directory defaults to $fontDir
|
||||
EOF
|
||||
)
|
||||
|
||||
err()
|
||||
{
|
||||
red="\033[31m"
|
||||
reset="\033[0m"
|
||||
for arg in "$@"; do
|
||||
printf "%berror%b: %s\n" "$red" "$reset" "$arg" >&2
|
||||
done
|
||||
}
|
||||
|
||||
while getopts ":htd:" opt; do
|
||||
case "$opt" in
|
||||
h)
|
||||
printf "%s\n" "$help"
|
||||
exit
|
||||
;;
|
||||
t)
|
||||
toiletFlag=1
|
||||
;;
|
||||
d)
|
||||
fontDir="$OPTARG"
|
||||
[ -d "$fontDir" ] || {
|
||||
err "directory '$fontDir' does not exist"
|
||||
exit 2
|
||||
}
|
||||
;;
|
||||
:)
|
||||
err "option -$OPTARG requires an argument"
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
err "invalid option -$OPTARG"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ "$#" -eq 0 ] && {
|
||||
echo "$help"
|
||||
exit 1
|
||||
}
|
||||
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
msg="$1"
|
||||
|
||||
[ -z "$msg" ] && {
|
||||
err "a message needs to be specified"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ -n "$toiletFlag" ]; then
|
||||
for i in "$fontDir"/*.flf "$fontDir"/*.tlf; do
|
||||
[ "$i" = "./*.flf" ] && err "no fonts exist in directory" && exit 1
|
||||
echo "Font: $(basename "$i" | sed 's,\.tlf,,g;s,\.flf,,g')"
|
||||
figlet -f "$i" "$msg" 2> /dev/null
|
||||
done
|
||||
else
|
||||
for i in "$fontDir"/*.flf; do
|
||||
[ "$i" = "./*.flf" ] && err "no fonts exist in directory" && exit 1
|
||||
echo "Font: $(basename "$i" | sed 's,\.flf,,g')"
|
||||
figlet -f "$i" "$msg" 2> /dev/null
|
||||
done
|
||||
fi
|
Loading…
Reference in New Issue