Skip to content

Commit

Permalink
update vars
Browse files Browse the repository at this point in the history
  • Loading branch information
fbnmtz committed Dec 9, 2024
1 parent 81f491a commit ca81f8b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 32 deletions.
15 changes: 12 additions & 3 deletions args
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
# Created: Friday, 2022/02/11 - 20:09:07
# Author.: @fbnmtz, fgm ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Sunday, 2024/12/08 - 19:21:30
# Last Modified: Monday, 2024/12/09 - 03:35:32
# Modified By..: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.2.16.1348
# Version: 0.2.16.1365
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
Expand Down Expand Up @@ -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
Expand Down
49 changes: 26 additions & 23 deletions init
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
# Created: Thursday, 2021/05/20 - 13:18:34
# Author.: @fbnmtz, fgm ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Sunday, 2024/12/08 - 04:28:46
# Last Modified: Monday, 2024/12/09 - 13:37:47
# Modified By..: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.1.18.628
# Version: 0.1.18.658
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
Expand All @@ -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

Expand All @@ -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_/"
"$_xSHELL_/lib/"
"$_xSHELL_/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() {
Expand Down Expand Up @@ -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"

Expand All @@ -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}"
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions xshell
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# Created: Thursday, 2020/02/18 - 20:44:58
# Author.: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Monday, 2024/12/09 - 00:55:59
# Last Modified: Monday, 2024/12/09 - 13:27:32
# Modified By..: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.1.19.363
# Version: 0.1.19.375
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions xshell.lib
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
# Created: Sunday, 2022/02/20 - 18:44:18
# Author.: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Monday, 2024/12/09 - 00:14:48
# Last Modified: Monday, 2024/12/09 - 04:10:28
# Modified By..: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.1.13.251
# Version: 0.1.13.253
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
Expand Down Expand Up @@ -121,7 +121,7 @@ templateScript(){
# -> variables created by or library system (don't worry)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
source \"\$_xSHELL_/init\"
source \"\$xSHELL_INIT\"
use args
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~"
Expand Down

0 comments on commit ca81f8b

Please sign in to comment.