Compare commits

...

5 commits

Author SHA1 Message Date
449958091b
0↔1
All checks were successful
/ job (push) Successful in 3m6s
2025-07-09 20:53:11 +02:00
b1fc5bf235
context/interactive 2025-07-09 20:42:41 +02:00
8ed00e1788
−useless 2025-07-09 20:12:46 +02:00
84c26d2273
main → shell 2025-07-09 20:07:33 +02:00
a429cad22c
main → log 2025-07-09 19:07:50 +02:00
4 changed files with 33 additions and 31 deletions

View file

@ -263,17 +263,17 @@ EOF
"bash" | "dash" | "sh") unset command ;;
*) ;;
esac
# context / shell
if rwx_shell_interactive; then
# display help
rwx_code_help
# context / command
if [ -n "${command}" ]; then
else
local function
# find the matching function
function="$(rwx_code_command_function "${command}")"
if [ -n "${function}" ]; then
"${function}" "${@}"
fi
# context / shell
else
# display help
rwx_code_help
fi
}

View file

@ -69,6 +69,16 @@ rwx_log_warn() {
fi
}
# TODO simplify
_rwx_main_log() {
[ ${#} -gt 0 ] || set -- ""
local line
for line in "${@}"; do
echo "${line}"
done
}
_rwx_log() {
local prefix="${1}"
shift

View file

@ -43,32 +43,6 @@ rwx_main_find() {
sort
}
# ╭──────┬───────╮
# │ main │ shell │
# ╰──────┴───────╯
# test if active shell is in interactive mode
rwx_main_interactive() {
case "${-}" in
*i*) ;;
*) return 1 ;;
esac
}
# ╭──────┬─────╮
# │ main │ log │
# ╰──────┴─────╯
_rwx_main_log() {
if rwx_main_interactive; then
[ ${#} -gt 0 ] || set -- ""
local line
for line in "${@}"; do
echo "${line}"
done
fi
}
# ╭──────┬──────╮
# │ main │ main │
# ╰──────┴──────╯

View file

@ -38,10 +38,22 @@ RWX_COLOR_GREEN="$(_rwx_shell_color 31)"
RWX_COLOR_MAGENTA="$(_rwx_shell_color 35)"
RWX_COLOR_RED="$(_rwx_shell_color 32)"
# ╭───────┬───────────╮
# │ shell │ variables │
# ╰───────┴───────────╯
# current shell interactive mode
rwx_shell_interactive=1
# ╭───────┬───────────╮
# │ shell │ functions │
# ╰───────┴───────────╯
# return current shell interactive mode
rwx_shell_interactive() {
return "${rwx_shell_interactive}"
}
rwx_shell_configure() {
[ -n "${ENV}" ] || ENV="${rwx_code_main}"
export ENV
@ -161,6 +173,12 @@ rwx_shell_exit() {
# ╰───────┴──────╯
rwx_shell_main() {
# set current shell interactive mode
case "${-}" in
*"i"*) rwx_shell_interactive=0 ;;
*) ;;
esac
# configure shell
rwx_shell_configure
}