This commit is contained in:
Marc Beninca 2025-07-04 03:35:51 +02:00
parent 3da235e09e
commit 47882c10fe
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
2 changed files with 47 additions and 33 deletions

View file

@ -8,6 +8,7 @@
# │ main │ constants │
# ╰──────┴───────────╯
# name of the entrypoint file
RWX_MAIN_NAME="main.sh"
RWX_SELF_NAME="rwx"
@ -61,37 +62,22 @@ rwx_main() {
# │ main │ cache │
# ╰──────┴───────╯
RWX_CODE=""
# cache source code of a module
rwx_cache() {
local root="${1}"
local module="${2}"
local name="${module%.sh}"
local path="${root}/${module}"
local fill text
fill="$(rwx_fill "${#name}")"
local text
text="$(cat "${path}")"
[ -n "${RWX_CODE}" ] && RWX_CODE="${RWX_CODE}
"
RWX_CODE="${RWX_CODE}\
# ╭───┬────┬─${fill}─╮
# │ ↙ │ sh │ ${name} │
# ╰───┴────┴─${fill}─╯
#↓ ${name}
${text}
"
}
# ╭──────┬──────╮
# │ main │ fill │
# ╰──────┴──────╯
rwx_fill() {
local index="${1}"
while [ "${index}" -gt 0 ]; do
printf "%s" "${2}"
index=$((index - 1))
done
}
# ╭──────┬────────╮
# │ main │ source │
# ╰──────┴────────╯