From f9ae00c92324cd9f4174ce17ac3c7ef59d7251dd Mon Sep 17 00:00:00 2001 From: Fabiano Matos Date: Mon, 9 Dec 2024 13:41:26 -0300 Subject: [PATCH] update vars --- args | 15 ++++++++++++--- init | 51 +++++++++++++++++++++++++++------------------------ xshell | 6 +++--- xshell.lib | 6 +++--- 4 files changed, 45 insertions(+), 33 deletions(-) diff --git a/args b/args index 1b866e1..2954a34 100755 --- a/args +++ b/args @@ -6,10 +6,10 @@ # Created: Friday, 2022/02/11 - 20:09:07 # Author.: @fbnmtz, fgm (fabiano.matoz@gmail.com) # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ -# Last Modified: Sunday, 2024/12/08 - 19:21:30 +# Last Modified: Monday, 2024/12/09 - 03:35:32 # Modified By..: @fbnmtz, (fabiano.matoz@gmail.com) # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ -# Version: 0.2.16.1348 +# Version: 0.2.16.1365 # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ # Description: # > @@ -444,9 +444,18 @@ xrun(){ ;; --xhelp) use utils - local _help_viewer=$(getPath bat less) + local _help_viewer=$(getPath bat less more cat) shift; xrunHelp | $_help_viewer ;; + --xlib-dirs) + shift; + [ -z "$RED" ] && use colors + echo -e "\n${YELLOW}Listing xSHELL LIB directories:${RESET}\n" + for dir in "${xSHELL_DIRS[@]}"; do + echo -e "${GREEN} \`-> directory '${dir}${RESET})" + done + exit + ;; *) _PARAMS_+=("$1") shift diff --git a/init b/init index 6fca35a..7262ba9 100644 --- a/init +++ b/init @@ -6,10 +6,10 @@ # Created: Thursday, 2021/05/20 - 13:18:34 # Author.: @fbnmtz, fgm (fabiano.matoz@gmail.com) # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ -# Last Modified: Sunday, 2024/12/08 - 04:28:46 +# Last Modified: Monday, 2024/12/09 - 13:53:25 # Modified By..: @fbnmtz, (fabiano.matoz@gmail.com) # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ -# Version: 0.1.18.628 +# Version: 0.1.18.660 # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ # Description: # > @@ -21,8 +21,7 @@ # _INIT_DEBUG_=false # set to true or false to DEBUG # shellcheck disable=SC1090 #warning on 'source' usage -[ "$_INIT_DEBUG_" == 'true' ] && \ - source "$_xSHELL_/colors" # autoload 'colors' if in DEBUG mode +[ "$_INIT_DEBUG_" == 'true' ] && source "$xSHELL_PATH/colors" # autoload 'colors' if in DEBUG mode # source /opt/xSHELL/colors # autoload 'colors' if in DEBUG mode # source ~/bin/xSHELL/colors # autoload 'colors' if in DEBUG mode @@ -32,6 +31,18 @@ APP=$(basename "$0") # application name APP_DIR=$(dirname "$0") # application current directory APP_HOME="" # application home (store data) +xSHELL_DIRS=( + "$APP_DIR/" + "$APP_DIR/lib/" + "$APP_DIR/vendor/" + "$xSHELL_PATH/" + "$xSHELL_PATH/lib/" + "$xSHELL_PATH/vendor/" + # "/opt/xSHELL/" + # "$HOME/bin/xSHELL/" + # "$HOME/bin/xSHELL/vendor/" + # "$HOME/bin/vendor/" +) # Função para definir um valor em um array associativo simulado set_assoc_array() { @@ -66,7 +77,7 @@ _USE_COUNT_=0 # function to set $APP_HOME # ex: setHome {dir1, dir2} xsetHome(){ - APP_HOME=~/.fbnmtz/$APP + APP_HOME=~/.xshell/$APP mkdir -p "$APP_HOME"/"$*" } @@ -118,31 +129,23 @@ use(){ if ! checkLibLoaded "$lib_file"; then # shellcheck disable=SC2155 # warning - declare and assign separate - local current_path=$(dirname "$0") - local lib_dirs=( - "$current_path/$lib_file" - "$current_path/lib/$lib_file" - "$current_path/vendor/$lib_file" - "$_xSHELL_/$lib_file" - "$_xSHELL_/lib/$lib_file" - "$_xSHELL_/vendor/$lib_file" - # "/opt/xSHELL/$lib_file" - # "$HOME/bin/xSHELL/$lib_file" - # "$HOME/bin/xSHELL/vendor/$lib_file" - # "$HOME/bin/vendor/$lib_file" - ) + local current_path=$(dirname "$0") local included='' # search file in default destinations local li=0 - for lib in "${lib_dirs[@]}"; do + for lib in "${xSHELL_DIRS[@]}"; do if source "$lib" 2> /dev/null ; then _CALLER_=$lib # success? set a flag; break loop [ "$_INIT_DEBUG_" == 'true' ] && { - echo -e "${GREEN} \`-> loading '${lib_dirs[$li]}'${RESET} - "\ - "${CYAN}directory: $((li+1))/${#lib_dirs[@]}${RESET})" + # printf " %-${max_length}s %s\n" "$key" "$desc" + + printf " %s\`-> loading '%s' %-25s - directory: %s/%s" "${GREEN}" "${xSHELL_DIRS[$li]}" "${RESET}" "${CYAN}" "$((li+1))" "${#xSHELL_DIRS[@]}${RESET}" + + # echo -e "${GREEN} \`-> loading '${xSHELL_DIRS[$li]}'${RESET} - "\ + # "${CYAN}directory: $((li+1))/${#xSHELL_DIRS[@]}${RESET})" } included="true" @@ -159,10 +162,9 @@ use(){ # not included with success? raise a error test -z "$included" && { - echo -e "\n${RED}Error importing lib '$lib_file'"\ - "- NOT_FOUND!${RESET}" + echo -e "\n${RED}Error importing lib '$lib_file' - NOT_FOUND!${RESET}" [ "$_INIT_DEBUG_" == 'true' ] && { - local all_dirs=${lib_dirs[*]} + local all_dirs=${xSHELL_DIRS[*]} echo -e "${RED} \`-> searched on dir's:\n *"\ "${all_dirs// /\\n \* }"\ "${RESET}" @@ -180,6 +182,7 @@ alias import=use alias require=use alias load=use alias unit=use +alias xuse=use # validade required binaries # ex: xrequirements bin1 bin2 bin3A:bin3B diff --git a/xshell b/xshell index cc7bd67..bd6548c 100755 --- a/xshell +++ b/xshell @@ -5,10 +5,10 @@ # Created: Thursday, 2020/02/18 - 20:44:58 # Author.: @fbnmtz, (fabiano.matoz@gmail.com) # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ -# Last Modified: Monday, 2024/12/09 - 00:55:59 +# Last Modified: Monday, 2024/12/09 - 13:27:32 # Modified By..: @fbnmtz, (fabiano.matoz@gmail.com) # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ -# Version: 0.1.19.363 +# Version: 0.1.19.375 # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ # Description: # > @@ -24,7 +24,7 @@ # -> ignore this warning because shellcheck cant detect variables created by or library system. # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~ -source "$_xSHELL_/init" +source "$xSHELL_INIT" use args utils strings xshell.lib xrequirements touch chmod date diff --git a/xshell.lib b/xshell.lib index c8422e8..352e9f5 100644 --- a/xshell.lib +++ b/xshell.lib @@ -6,10 +6,10 @@ # Created: Sunday, 2022/02/20 - 18:44:18 # Author.: @fbnmtz, (fabiano.matoz@gmail.com) # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ -# Last Modified: Monday, 2024/12/09 - 00:14:48 +# Last Modified: Monday, 2024/12/09 - 04:10:28 # Modified By..: @fbnmtz, (fabiano.matoz@gmail.com) # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ -# Version: 0.1.13.251 +# Version: 0.1.13.253 # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~ # Description: # > @@ -121,7 +121,7 @@ templateScript(){ # -> variables created by or library system (don't worry) # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~ -source \"\$_xSHELL_/init\" +source \"\$xSHELL_INIT\" use args # ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~"