From 359ac4e2c07334aae7f98e5eb4a1ba3b4888be7b Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Tue, 25 Feb 2025 23:49:22 +0200 Subject: [PATCH] chore(dfm): cleanup, fixes --- local/dfm/cmd/install.sh | 19 ++++++++-------- local/dfm/lib/common.sh | 8 +++---- local/dfm/lib/utils.sh | 47 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 14 deletions(-) diff --git a/local/dfm/cmd/install.sh b/local/dfm/cmd/install.sh index a4744d1..1f01f8f 100755 --- a/local/dfm/cmd/install.sh +++ b/local/dfm/cmd/install.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # Installation functions for dfm, the dotfile manager # # @author Ismo Vuorinen @@ -9,7 +10,7 @@ function all() lib::log "Installing all packages..." fonts brew - asdf + cargo } # @description Install fonts @@ -19,15 +20,6 @@ function fonts() # implement fonts installation } -# Install asdf and set it up. -# -# @description Install asdf -function asdf() -{ - lib::log "Installing asdf..." - # implement asdf installation -} - # Install Homebrew and set it up. # # @description Installs Homebrew @@ -36,3 +28,10 @@ function brew() lib::log "Installing Homebrew..." # implement Homebrew installation } + +# @description Install Rust and cargo packages. +function cargo() +{ + lib::log "Installing Rust and cargo packages..." + # implement Rust and cargo packages installation +} diff --git a/local/dfm/lib/common.sh b/local/dfm/lib/common.sh index aef8731..64934c4 100755 --- a/local/dfm/lib/common.sh +++ b/local/dfm/lib/common.sh @@ -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'" ;; *) diff --git a/local/dfm/lib/utils.sh b/local/dfm/lib/utils.sh index a0828be..e82cd37 100755 --- a/local/dfm/lib/utils.sh +++ b/local/dfm/lib/utils.sh @@ -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