main/source
This commit is contained in:
parent
cd1701fb71
commit
b342a2c9e1
1 changed files with 28 additions and 27 deletions
55
sh/main.sh
55
sh/main.sh
|
@ -37,33 +37,6 @@ RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}"
|
||||||
# path to the entrypoint main file of the project
|
# path to the entrypoint main file of the project
|
||||||
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
|
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
|
||||||
|
|
||||||
# ╭──────┬────────╮
|
|
||||||
# │ main │ source │
|
|
||||||
# ╰──────┴────────╯
|
|
||||||
|
|
||||||
# source code from file path
|
|
||||||
rwx_source() {
|
|
||||||
local root="${1}"
|
|
||||||
[ -d "${root}" ] ||
|
|
||||||
return 1
|
|
||||||
local file="${2}"
|
|
||||||
local count module modules
|
|
||||||
count=0
|
|
||||||
__rwx_log "" \
|
|
||||||
". ${root}"
|
|
||||||
modules="$(rwx_find_shell "${root}" "${file}")"
|
|
||||||
while IFS= read -r module; do
|
|
||||||
count=$((count + 1))
|
|
||||||
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
|
|
||||||
# shellcheck disable=SC1090
|
|
||||||
. "${root}/${module}"
|
|
||||||
# cache code
|
|
||||||
rwx_cache "${root}" "${module}"
|
|
||||||
done <<EOF
|
|
||||||
${modules}
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
# ╭──────┬─────╮
|
# ╭──────┬─────╮
|
||||||
# │ main │ log │
|
# │ main │ log │
|
||||||
# ╰──────┴─────╯
|
# ╰──────┴─────╯
|
||||||
|
@ -119,12 +92,40 @@ rwx_find_shell() {
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
# ╭──────┬────────╮
|
||||||
|
# │ main │ source │
|
||||||
|
# ╰──────┴────────╯
|
||||||
|
|
||||||
|
# source code from file path
|
||||||
|
rwx_source() {
|
||||||
|
local root="${1}"
|
||||||
|
[ -d "${root}" ] ||
|
||||||
|
return 1
|
||||||
|
local file="${2}"
|
||||||
|
local count module modules
|
||||||
|
count=0
|
||||||
|
__rwx_log "" \
|
||||||
|
". ${root}"
|
||||||
|
modules="$(rwx_find_shell "${root}" "${file}")"
|
||||||
|
while IFS= read -r module; do
|
||||||
|
count=$((count + 1))
|
||||||
|
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
. "${root}/${module}"
|
||||||
|
# cache code
|
||||||
|
rwx_cache "${root}" "${module}"
|
||||||
|
done <<EOF
|
||||||
|
${modules}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
# ╭──────┬───────╮
|
# ╭──────┬───────╮
|
||||||
# │ main │ cache │
|
# │ main │ cache │
|
||||||
# ╰──────┴───────╯
|
# ╰──────┴───────╯
|
||||||
|
|
||||||
# cache source code of a module
|
# cache source code of a module
|
||||||
# inside a global code variable
|
# inside a global code variable
|
||||||
|
#> cat
|
||||||
rwx_cache() {
|
rwx_cache() {
|
||||||
local root="${1}"
|
local root="${1}"
|
||||||
local module="${2}"
|
local module="${2}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue