91 lines
1.6 KiB
Bash
91 lines
1.6 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
inverse="$(tput setab 7)$(tput setaf 0)"
|
|
success="$(tput setab 2)$(tput bold)"
|
|
error="$(tput setab 1)$(tput bold)"
|
|
underline=$(tput smul)
|
|
reset=$(tput sgr0)
|
|
|
|
export BOG_TITLE_PRINTED=0
|
|
|
|
# Set pipefail option
|
|
# Exit status of overall pipe
|
|
# instead of last one
|
|
set -o pipefail
|
|
# Avoid spawning subshell
|
|
# Needed for title to be able
|
|
# to be globally updated inside pipe
|
|
shopt -s lastpipe
|
|
|
|
__print_title_header () {
|
|
echo " *************************** "
|
|
echo " ********************************* "
|
|
echo " ****"
|
|
echo "*****"
|
|
}
|
|
|
|
__check_last_pipe_status () {
|
|
local last_index=$((${#PIPESTATUS[@]}-1))
|
|
local last_exit_code=${PIPESTATUS[$last_index]}
|
|
echo "DEBUG: $last_index, $last_exit_code"
|
|
return last_exit_code
|
|
}
|
|
|
|
title () {
|
|
if [[ $BOG_TITLE_PRINTED -eq 0 ]]
|
|
then
|
|
__print_title_header
|
|
BOG_TITLE_PRINTED=1
|
|
fi
|
|
|
|
read title
|
|
echo "***** $title"
|
|
}
|
|
|
|
footer () {
|
|
echo "***** *****"
|
|
echo "***** END OF SCRIPT *****"
|
|
echo " **** **** "
|
|
echo " ********************************* "
|
|
echo " *********************** "
|
|
}
|
|
|
|
section () {
|
|
read title
|
|
echo ":::::"
|
|
echo ":(*) $title..."
|
|
}
|
|
|
|
result () {
|
|
local exit_code=$?
|
|
|
|
if [ $exit_code -eq 0 ]
|
|
then
|
|
echo ":)=> $success Ok $reset ****"
|
|
else
|
|
echo ":(!> $error Error $reset ****"
|
|
fi
|
|
}
|
|
|
|
output () {
|
|
while read line
|
|
do
|
|
#[ -z "$line" ] && break
|
|
echo "::::| $line"
|
|
done
|
|
}
|
|
|
|
output::warning () {
|
|
while read line
|
|
do
|
|
echo ":::<!> $line"
|
|
done
|
|
}
|
|
|
|
output::info () {
|
|
while read line
|
|
do
|
|
echo ":::<?> $line"
|
|
done
|
|
}
|