_msg: Refactor to enable escaped commands
This commit is contained in:
parent
7805e4a89b
commit
29a09faf16
34
qsgen2
34
qsgen2
@ -77,39 +77,25 @@ function _msg() {
|
||||
local full_msg=""
|
||||
for arg in "$@"; do
|
||||
if [[ -n "${qsgenlang[$arg]}" ]]; then
|
||||
# echo "Found key: $arg" # Debug line to confirm key is found
|
||||
full_msg+="${qsgenlang[$arg]}"
|
||||
else
|
||||
# echo "Key not found: $arg" # Debug line for keys not found
|
||||
full_msg+="$arg"
|
||||
fi
|
||||
done
|
||||
|
||||
# Apply color formatting based on type and use printf for safe output
|
||||
# Determine the color based on the type
|
||||
local color="${end}" # Default to no color if type is unrecognized
|
||||
case $type in
|
||||
std)
|
||||
printf "${green}%s${end}\n" "${full_msg}"
|
||||
;;
|
||||
info)
|
||||
printf "${yellow}%s${end}\n" "${full_msg}"
|
||||
;;
|
||||
debug)
|
||||
printf "${red}%s${end}\n" "${full_msg}"
|
||||
;;
|
||||
other)
|
||||
printf "${bold_yellow}%s${end}\n" "${full_msg}"
|
||||
;;
|
||||
sub)
|
||||
printf "${magenta}%s${end}\n" "${full_msg}"
|
||||
;;
|
||||
main)
|
||||
printf "${white}${green_bg} %s ${end}\n" "${full_msg}"
|
||||
;;
|
||||
*)
|
||||
printf "%s\n" "${full_msg}"
|
||||
;;
|
||||
std) color="${green}" ;;
|
||||
info) color="${yellow}" ;;
|
||||
debug) color="${red}" ;;
|
||||
other) color="${bold_yellow}" ;;
|
||||
sub) color="${magenta}" ;;
|
||||
main) color="${white}${green_bg}" ;;
|
||||
esac
|
||||
|
||||
# Use printf with %b to allow backslash escape interpretation
|
||||
printf "${color}%b${end}\n" "${full_msg}"
|
||||
}
|
||||
|
||||
function _version() {
|
||||
|
Loading…
Reference in New Issue
Block a user