diff --git a/sh/core/code.sh b/sh/core/code.sh index c87ad35..356e757 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -57,18 +57,6 @@ rwx_code_cache_user() { echo "${rwx_code_cache_user}" } -# ╭──────┬──────╮ -# │ code │ help │ -# ╰──────┴──────╯ - -# output help message -rwx_code_help() { - rwx_log "" \ - "rwx_… = functions" \ - " a__… = aliases" \ - " u__… = user" -} - # ╭──────┬─────────╮ # │ code │ install │ # ╰──────┴─────────╯ @@ -296,26 +284,4 @@ ${rwx_code_modules_user} EOF # load code cache rwx_code_load - # set command - local command - # command name used to run - # (stripped from hyphen interactive flag) - command="$(basename "${0}" | sed "s|^-||")" - case "${command}" in - "bash" | "dash" | "sh") unset command ;; - *) ;; - esac - # context / shell - if rwx_shell_interactive; then - # display help - rwx_code_help - # context / command - else - local function - # find the matching function - function="$(rwx_code_command_function "${command}")" - if [ -n "${function}" ]; then - "${function}" "${@}" - fi - fi } diff --git a/sh/log/log.sh b/sh/log/log.sh index 3921b8a..60c155c 100644 --- a/sh/log/log.sh +++ b/sh/log/log.sh @@ -35,6 +35,10 @@ _rwx_log() { done } +# ╭─────┬────────╮ +# │ log │ levels │ +# ╰─────┴────────╯ + rwx_log_fatal() { local code="${1}" shift diff --git a/sh/main.sh b/sh/main.sh index 09d3cd0..f14f6e7 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -53,6 +53,7 @@ rwx_main_find() { # run required initial steps #< core/code +#< core/shell rwx_main_main() { local module local modules @@ -70,6 +71,8 @@ ${modules} EOF # run code module main function with found main modules rwx_code_main "${modules}" "${@}" + # run shell module main function + rwx_shell_main } # run main function diff --git a/sh/shell/0.sh b/sh/shell/0.sh index 415d371..b0e5027 100644 --- a/sh/shell/0.sh +++ b/sh/shell/0.sh @@ -49,6 +49,14 @@ rwx_shell_interactive=1 # │ shell │ functions │ # ╰───────┴───────────╯ +# output help message +rwx_shell_help() { + rwx_log "" \ + "rwx_… = functions" \ + " a__… = aliases" \ + " u__… = user" +} + # return current shell interactive mode rwx_shell_interactive() { return "${rwx_shell_interactive}" @@ -180,6 +188,25 @@ rwx_shell_main() { esac # configure shell rwx_shell_configure + # context / shell + if rwx_shell_interactive; then + # display help + rwx_shell_help + # context / command + else + local command + local function + # command name used to run + # (stripped from hyphen interactive flag) + command="$(basename "${0}" | sed "s|^-||")" + case "${command}" in + "bash" | "dash" | "sh") unset command ;; + *) ;; + esac + # find the matching function + function="$(rwx_code_command_function "${command}")" + if [ -n "${function}" ]; then + "${function}" "${@}" + fi + fi } - -rwx_shell_main