diff --git a/sh/main.sh b/sh/main.sh index 75036ef..8d950b0 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,5 +1,4 @@ #! /usr/bin/env sh -# main module # ╭──────╮ # │ main │ @@ -9,7 +8,6 @@ # │ main │ constants │ # ╰──────┴───────────╯ -# name of the entrypoint file RWX_MAIN_NAME="main.sh" RWX_SELF_NAME="rwx" @@ -63,20 +61,44 @@ 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 text + local fill text + fill="$(rwx_fill "${#name}" ─)" text="$(cat "${path}")" - RWX_CODE="${RWX_CODE}\ -#↓ ${name} -${text} -" + case "${text}" in + "#!"*) + RWX_CODE="${text} + +# ╭───┬────┬─${fill}─╮ +# │ ↖ │ sh │ ${name} │ +# ╰───┴────┴─${fill}─╯" + ;; + *) + RWX_CODE="${RWX_CODE} + +# ╭───┬────┬─${fill}─╮ +# │ ↙ │ sh │ ${name} │ +# ╰───┴────┴─${fill}─╯ + +${text}" + ;; + esac +} + +# ╭──────┬──────╮ +# │ main │ fill │ +# ╰──────┴──────╯ + +rwx_fill() { + local index="${1}" + while [ "${index}" -gt 0 ]; do + printf "%s" "${2}" + index=$((index - 1)) + done } # ╭──────┬────────╮ @@ -93,17 +115,16 @@ rwx_source() { count=0 __rwx_log "" \ ". ${root}" - local modules="$(rwx_find_shell "${root}" "${file}")" - while IFS= read -r module; do + rwx_ifs_set + for module in $(rwx_find_shell "${root}" "${file}"); do count=$((count + 1)) __rwx_log "$(printf "%02d" "${count}") ${module%.sh}" # shellcheck disable=SC1090 . "${root}/${module}" # cache code rwx_cache "${root}" "${module}" - done <