generated from pmo-actions/healthchecks-ping
Ajouter bashlib.sh
This commit is contained in:
65
bashlib.sh
Normal file
65
bashlib.sh
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
GREEN='\033[0;32m'
|
||||||
|
RED='\033[0;31m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
|
||||||
|
debug() {
|
||||||
|
if [[ -n "$DEBUG" ]]; then
|
||||||
|
local prompt="$1"
|
||||||
|
shift
|
||||||
|
local message="$*"
|
||||||
|
|
||||||
|
if [[ -n "$message" ]] ; then
|
||||||
|
message=": $message"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "🐛 \033[0;36m[DEBUG] ${prompt}\033[0m${message}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
error() {
|
||||||
|
local prompt="$1"
|
||||||
|
shift
|
||||||
|
local message="$*"
|
||||||
|
|
||||||
|
if [[ -n "$message" ]] ; then
|
||||||
|
message=": $message"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${RED}❌ ${prompt}:${NC}${message}"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
step() {
|
||||||
|
local prompt="$1"
|
||||||
|
shift
|
||||||
|
local message="$*"
|
||||||
|
|
||||||
|
if [[ -n "$message" ]] ; then
|
||||||
|
message=": $message"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${YELLOW}🔄 ${prompt}${NC}${message}"
|
||||||
|
}
|
||||||
|
|
||||||
|
success() {
|
||||||
|
local prompt="$1"
|
||||||
|
shift
|
||||||
|
local message="$*"
|
||||||
|
|
||||||
|
if [[ -n "$message" ]] ; then
|
||||||
|
message=": $message"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN}✅ ${prompt}${NC}${message}"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_command() {
|
||||||
|
local command="$1"
|
||||||
|
|
||||||
|
if [[ -z $(which ${command}) ]] ; then
|
||||||
|
error "Missing command" "${command}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user