diff --git a/sh/core/code.sh b/sh/core/code.sh index 356e757..c87ad35 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -57,6 +57,18 @@ 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 │ # ╰──────┴─────────╯ @@ -284,4 +296,26 @@ ${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 60c155c..3921b8a 100644 --- a/sh/log/log.sh +++ b/sh/log/log.sh @@ -35,10 +35,6 @@ _rwx_log() { done } -# ╭─────┬────────╮ -# │ log │ levels │ -# ╰─────┴────────╯ - rwx_log_fatal() { local code="${1}" shift diff --git a/sh/main.sh b/sh/main.sh index f14f6e7..09d3cd0 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -53,7 +53,6 @@ rwx_main_find() { # run required initial steps #< core/code -#< core/shell rwx_main_main() { local module local modules @@ -71,8 +70,6 @@ ${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 b0e5027..415d371 100644 --- a/sh/shell/0.sh +++ b/sh/shell/0.sh @@ -49,14 +49,6 @@ 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}" @@ -188,25 +180,6 @@ 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