Compare commits
5 commits
333da5fb6a
...
449958091b
Author | SHA1 | Date | |
---|---|---|---|
449958091b | |||
b1fc5bf235 | |||
8ed00e1788 | |||
84c26d2273 | |||
a429cad22c |
4 changed files with 33 additions and 31 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
26
sh/main.sh
26
sh/main.sh
|
@ -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 │
|
||||
# ╰──────┴──────╯
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue