diff --git a/pacman-zfs-snapshot.sh b/pacman-zfs-snapshot.sh index 0bf380d..7c74832 100755 --- a/pacman-zfs-snapshot.sh +++ b/pacman-zfs-snapshot.sh @@ -31,6 +31,32 @@ if [[ ! "${snap_op_installation_suffix}" ]]; then snap_op_installation_suffix='i if [[ ! "${snap_op_remove_suffix}" ]]; then snap_op_remove_suffix='rmvl'; fi if [[ ! "${snap_op_upgrade_suffix}" ]]; then snap_op_upgrade_suffix='upgr'; fi +function pprint () { + local style msg exit_code + style="${1:?}" + msg="${2:?}" + exit_code="${3}" + + local color_reset color_lyellow + color_reset='\e[0m' + color_lyellow='\e[93m' + color_red='\e[31m' + + case "${style}" in + warn) + printf -- "${color_lyellow}"'[WARN]'"${color_reset}"' %s\n' "${msg}" + ;; + err) + printf -- "${color_red}"'[ERR]'"${color_reset}"' %s\n' "${msg}" + ;; + *) + printf -- '[INFO] %s\n' "${msg}" + ;; + esac + + [[ "${exit_code}" ]] && exit "${exit_code}" +} + function split_pkgs_by_importance () { local pkgs_in_transaction pkgs_in_transaction=("${@}")