This repository has been archived by the owner on Sep 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibsay
81 lines (70 loc) · 1.58 KB
/
libsay
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
#
# FlightGear Installer
# libsay
# Library that adds the command "say" to print nice looking messages.
#
# Author: Megaf - https://github.com/Megaf - mmegaf [at] gmail [dot] com
# Date: 03/09/2022
# GitHub: https://github.com/Megaf/FlightGear-Installer
# License: GPL V3
c_error()
{
tput smul
tput setab 0
tput setaf 1
tput rmul
}
c_info()
{
tput setab 0
tput setaf 2
}
c_warning()
{
tput smul
tput smso
tput setab 0
tput setaf 3
tput rmso
tput rmul
}
c_debug()
{
tput setab 0
tput setaf 6
}
print_message()
{
tput sgr0
tput bold
[[ "$message" == "ERROR:"* ]] || [[ "$message" == "ERR:"* ]] && c_error
[[ "$message" == "INFO:"* ]] && c_info
[[ "$message" == "WARN:"* ]] || [[ "$message" == "WARNING:"* ]] && c_warning
[[ "$message" == "DEBUG:"* ]] && c_debug
printf "$message"
tput sgr0
}
say ()
{
message="$*"
if [[ ! "$debug" == "true" ]] && [[ ! "$message" == "DEBUG:"* ]]
then
say_function
elif [[ "$debug" == "true" ]]
then
say_function
fi
}
say_function ()
{
local length=$(expr length "$message")
local spacesize="4"
local linesize=$(expr $spacesize + $length + $spacesize)
tput sgr0
printf "╔"; printf "%0.s═" $(seq 1 $linesize); printf "╗\n"
printf "║"; printf "%0.s " $(seq 1 $spacesize); print_message; printf "%0.s " $(seq 1 $spacesize); printf "║\n"
printf "╚"; printf "%0.s═" $(seq 1 $linesize); printf "╝\n"
tput sgr0
unset $* message length spacesize linesize
}