main/main

This commit is contained in:
Marc Beninca 2025-07-08 05:50:46 +02:00
parent 820ec05b13
commit 1345f07e16
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
2 changed files with 8 additions and 12 deletions

View file

@ -76,9 +76,9 @@ _rwx_log() {
local line
for line in "${@}"; do
if [ -n "${prefix}" ]; then
__rwx_log "${prefix} ${line}"
_rwx_main_log "${prefix} ${line}"
else
__rwx_log "${line}"
_rwx_main_log "${line}"
fi
done
}

View file

@ -69,7 +69,7 @@ rwx_shell_interactive() {
# │ main │ log │
# ╰──────┴─────╯
__rwx_log() {
_rwx_main_log() {
if rwx_shell_interactive; then
[ ${#} -gt 0 ] || set -- ""
local line
@ -91,12 +91,12 @@ rwx_source() {
local file="${2}"
local count module modules
count=0
__rwx_log "" \
_rwx_main_log "" \
". ${root}"
modules="$(rwx_find_shell "${root}" "${file}")"
while IFS= read -r module; do
count=$((count + 1))
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
_rwx_main_log "$(printf "%02d" "${count}") ${module%.sh}"
# shellcheck disable=SC1090
. "${root}/${module}"
# cache code
@ -133,21 +133,17 @@ ${text}
# run initial steps
#< code
rwx_main() {
rwx_main_main() {
# cache main
rwx_cache "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"
# source system root
if ! rwx_source "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"; then
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
_rwx_main_log "Not a directory: ${RWX_ROOT_SYSTEM}"
return 1
fi
# run code main function
rwx_code_main
}
# ╭──────┬─────╮
# │ main │ run │
# ╰──────┴─────╯
# run main function
rwx_main "${@}"
rwx_main_main "${@}"