cards/946724653816--llama-extract/assets/raw.sh
#!/usr/bin/env bash
(return 0 2>/dev/null) && { echo 'Do not source'; return 2; }
trap 'q' INT TERM
q() {
echo "bye"
exit 0
}
# Check required commands
for cmd in printf read seq; do
command -v "$cmd" >/dev/null || { echo "missing: $cmd"; exit 2; }
done
# Function to print a horizontal line of given length
L() {
printf -- '-%.0s' $(seq 1 "$1")
}
# ASCII art of a llama (renown source: https://emojicombos.com/llama-ascii-art)
llama_art() {
cat <<'EOF'
__
/ \__
( @\___
/ O
/ (_____/
/_____/ U
EOF
}
# Print a simple menu with borders
print_menu() {
local width=40
L "$width"
printf "\n"
printf "| %-36s |\n" "Llama ASCII Art Viewer"
L "$width"
printf "\n"
printf "| %-36s |\n" "Commands:"
printf "| %-36s |\n" " a - show ASCII art"
printf "| %-36s |\n" " q - quit"
L "$width"
printf "\n"
}
while :; do
print_menu
read -r -p '> ' x
case "$x" in
[aA])
llama_art
;;
[qQ])
q
;;
*)
echo "Unknown command: '$x'. Use 'a' to show llama, 'q' to quit."
;;
esac
done