Created
July 10, 2022 01:54
-
-
Save bugcy013/945827580c100226d40ad96b5fc1a219 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Begin Standard 'imports' | |
set -e | |
set -o pipefail | |
gray="\\e[37m" | |
blue="\\e[36m" | |
red="\\e[31m" | |
yellow="\\e[33m" | |
green="\\e[32m" | |
reset="\\e[0m" | |
info() { echo -e "${blue}INFO: $*${reset}"; } | |
error() { echo -e "${red}ERROR: $*${reset}"; } | |
debug() { | |
if [[ "${DEBUG}" == "true" ]]; then | |
echo -e "${gray}DEBUG: $*${reset}"; | |
fi | |
} | |
success() { echo -e "${green}✔ $*${reset}"; } | |
warn() { echo -e "${yellow}✖ $*${reset}"; exit 1; } | |
fail() { echo -e "${red}✖ $*${reset}"; exit 1; } | |
## Enable debug mode. | |
enable_debug() { | |
if [[ "${DEBUG}" == "true" ]]; then | |
info "Enabling debug mode." | |
set -x | |
fi | |
} | |
# Execute a command, saving its output and exit status code, and echoing its output upon completion. | |
# Globals set: | |
# status: Exit status of the command that was executed. | |
# output: Output generated from the command. | |
# | |
run() { | |
echo "$@" | |
set +e | |
output=$("$@" 2>&1) | |
status=$? | |
set -e | |
echo "${output}" | |
} | |
# End standard 'imports' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment