From 79a8584fde4dca0e541f41c2a9c9d92cbe04a1fd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 10 Jul 2025 04:02:44 +0200 Subject: [PATCH 1/3] context/command --- sh/core/code.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sh/core/code.sh b/sh/core/code.sh index c87ad35..28f5c06 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -296,22 +296,21 @@ ${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 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 From 80949cf6c077c0a4a76c6070c85ef5bbdbb1ba66 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 10 Jul 2025 04:33:43 +0200 Subject: [PATCH 2/3] main/shell --- sh/log/log.sh | 4 ++++ sh/main.sh | 3 +++ sh/shell/0.sh | 2 -- 3 files changed, 7 insertions(+), 2 deletions(-) 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..6eb5989 100644 --- a/sh/shell/0.sh +++ b/sh/shell/0.sh @@ -181,5 +181,3 @@ rwx_shell_main() { # configure shell rwx_shell_configure } - -rwx_shell_main From 5225d6a1ae26f49941d564d278fd54c3d7694a1b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 10 Jul 2025 04:39:14 +0200 Subject: [PATCH 3/3] shell/context,help --- sh/core/code.sh | 33 --------------------------------- sh/shell/0.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/sh/core/code.sh b/sh/core/code.sh index 28f5c06..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,25 +284,4 @@ ${rwx_code_modules_user} EOF # load code cache rwx_code_load - # context / shell - if rwx_shell_interactive; then - # display help - rwx_code_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 } diff --git a/sh/shell/0.sh b/sh/shell/0.sh index 6eb5989..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,4 +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 }