Refactor common messages into functions

This commit is contained in:
Ethan P
2019-09-25 15:59:54 -07:00
parent 12bf16b199
commit a472f1c651
3 changed files with 22 additions and 4 deletions

View File

@@ -52,7 +52,25 @@ printc_init() {
esac
}
# Initialization.
# Print a warning message to STDERR.
# Arguments:
# 1 -- The printc formatting string.
# ... -- The printc formatting arguments.
print_warning() {
printc "%{YELLOW}[%s warning]%{CLEAR}: $1%{CLEAR}\n" "$PROGRAM" "${@:2}" 1>&2
}
# Print an error message to STDERR.
# Arguments:
# 1 -- The printc formatting string.
# ... -- The printc formatting arguments.
print_error() {
printc "%{RED}[%s error]%{CLEAR}: $1%{CLEAR}\n" "$PROGRAM" "${@:2}" 1>&2
}
# -----------------------------------------------------------------------------
# Initialization:
# -----------------------------------------------------------------------------
printc_init <<END
CLEAR \x1B[0m
RED \x1B[31m