re-ordered functions, added logging to boxline

This commit is contained in:
alanw 2023-05-09 16:04:32 -07:00
parent f61e810829
commit 718e324a6b

View file

@ -321,7 +321,7 @@ boxbottom() {
}
boxline() {
echo -e "$left_border $1\r${ESC}[${BOXWIDTH}C$right_border"
logger echo -e "$left_border $1\r${ESC}[${BOXWIDTH}C$right_border"
}
boxseparator(){
@ -329,6 +329,25 @@ boxseparator(){
echo
}
boxborder(){
boxtop
for line in "$@" ; do
boxline "$line"
done
boxbottom
}
subboxborder(){
BOXWIDTH_ORG=$BOXWIDTH
BOXWIDTH=$(($BOXWIDTH*75/100))
boxline $(boxtop)
for line in "$@" ; do
boxline $(boxline "$line")
done
boxline $(boxbottom)
BOXWIDTH=$BOXWIDTH_ORG
}
# # For printing center-justified text. To change the padding character, replace the ' ' <~~ whitespace in front of the '{' in the padding variable
# center() {
# padding="$(printf '%0.1s' {1..500})"
@ -355,50 +374,7 @@ spanner() {
printf "%s %s %s\n" "$1" "$_spanner" "$2";
}
boxborder(){
boxtop
for line in "$@" ; do
boxline "$line"
done
boxbottom
}
subboxborder(){
BOXWIDTH_ORG=$BOXWIDTH
BOXWIDTH=$(($BOXWIDTH*75/100))
boxline $(boxtop)
for line in "$@" ; do
boxline $(boxline "$line")
done
boxline $(boxbottom)
BOXWIDTH=$BOXWIDTH_ORG
}
success(){
_line="$@"
echo -e "\n"
logger boxborder "${scriptname} ${grn}SUCCESS${dfl} ${_line}"
exit 0
}
warn(){
ec=$?
_line="$@"
echo -e "\n"
boxtop
logger boxline "${lrd}WARNING${lyl}[${ong}code=${red}$ec${lyl}]: ${_line}${dfl}"
boxbottom
}
fail(){
ec=$?
_line="$@"
echo -e "\n"
boxtop
logger boxline "${lrd}FAILED${lyl}[${ong}code=${red}$ec${lyl}]: ${_line}${dfl}"
boxbottom
exit $ec
}
# Workflow and logging
pushd(){
command pushd "$@" > /dev/null
@ -530,6 +506,32 @@ install-dir() {
# Utilities
success(){
_line="$@"
echo -e "\n"
logger boxborder "${scriptname} ${grn}SUCCESS${dfl} ${_line}"
exit 0
}
warn(){
ec=$?
_line="$@"
echo -e "\n"
boxtop
logger boxline "${lrd}WARNING${lyl}[${ong}code=${red}$ec${lyl}]: ${_line}${dfl}"
boxbottom
}
fail(){
ec=$?
_line="$@"
echo -e "\n"
boxtop
logger boxline "${lrd}FAILED${lyl}[${ong}code=${red}$ec${lyl}]: ${_line}${dfl}"
boxbottom
exit $ec
}
clone-repo(){
# git clone <source url> <destination>
local _url=$1