bashbot-lib/viewer.sh

21 lines
471 B
Bash
Raw Normal View History

2023-03-21 16:37:41 -03:00
#!/bin/bash
# this is just a library
# you will need to provide the following in the implementation:
# 1. a bash associative array populated by the library's functions
print_dashes(){
term_cols="$(tput cols)"
for ((i = 0; i < "${term_cols}"; i++)); do
printf -- "-"
done
}
view_content(){
local -n _REF="${1}"
print_dashes; printf "\n"
for i in "${!_REF[@]}"; do
[ ! -z "${_REF[${i}]}" ] && printf "[%s] \t=\t%s\n" "${i}" "${_REF[${i}]}"
done
}