chore(dfm): cleanup, fixes

This commit is contained in:
2025-02-25 23:49:22 +02:00
parent 255c8fdce7
commit 359ac4e2c0
3 changed files with 60 additions and 14 deletions

View File

@@ -65,16 +65,16 @@ lib::error::handle()
local command=$2
case $exit_code in
${ERROR_CODES[INVALID_ARGUMENT]})
"${ERROR_CODES[INVALID_ARGUMENT]}")
lib::error "Invalid argument at line $line_no in command '$command'"
;;
${ERROR_CODES[COMMAND_NOT_FOUND]})
"${ERROR_CODES[COMMAND_NOT_FOUND]}")
lib::error "Command not found at line $line_no"
;;
${ERROR_CODES[FUNCTION_NOT_FOUND]})
"${ERROR_CODES[FUNCTION_NOT_FOUND]}")
lib::error "Function not found at line $line_no in command '$command'"
;;
${ERROR_CODES[EXECUTION_FAILED]})
"${ERROR_CODES[EXECUTION_FAILED]}")
lib::error "Execution failed at line $line_no in command '$command'"
;;
*)

View File

@@ -23,6 +23,52 @@ readonly MAGENTA="\033[35m"
readonly CYAN="\033[36m"
readonly WHITE="\033[37m"
clr::black()
{
printf "${BLACK}%s${RESET}" "$*"
}
clr::red()
{
printf "${RED}%s${RESET}" "$*"
}
clr::green()
{
printf "${GREEN}%s${RESET}" "$*"
}
clr::yellow()
{
printf "${YELLOW}%s${RESET}" "$*"
}
clr::blue()
{
printf "${BLUE}%s${RESET}" "$*"
}
clr::magenta()
{
printf "${MAGENTA}%s${RESET}" "$*"
}
clr::white()
{
printf "${WHITE}%s${RESET}" "$*"
}
style::bold()
{
printf "${BOLD}%s${RESET}" "$*"
}
style::dim()
{
printf "${DIM}%s${RESET}" "$*"
}
style::italic()
{
printf "${ITALIC}%s${RESET}" "$*"
}
style::underline()
{
printf "${UNDERLINE}%s${RESET}" "$*"
}
# Function to print formatted line
list::print_formatted()
{
@@ -321,6 +367,7 @@ main::execute_command()
fi
# Source the command file
# shellcheck source=/dev/null
source "$cmd_file"
# Check if the function exists