shell/context,help
All checks were successful
/ job (push) Successful in 2m57s

This commit is contained in:
Marc Beninca 2025-07-10 04:39:14 +02:00
parent 80949cf6c0
commit 5225d6a1ae
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
2 changed files with 29 additions and 33 deletions

View file

@ -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
}

View file

@ -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
}