code/main
This commit is contained in:
parent
389f73a0b9
commit
d9a6e33409
2 changed files with 35 additions and 33 deletions
31
sh/code.sh
31
sh/code.sh
|
@ -181,3 +181,34 @@ rwx_code_parse() {
|
||||||
--assign action="${action}" \
|
--assign action="${action}" \
|
||||||
"${_rwx_code_awk}"
|
"${_rwx_code_awk}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ╭──────┬──────╮
|
||||||
|
# │ code │ main │
|
||||||
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
|
rwx_code_main() {
|
||||||
|
# source user root
|
||||||
|
rwx_source "${RWX_SELF_USER}"
|
||||||
|
# load code cache
|
||||||
|
rwx_code_load
|
||||||
|
# context / 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
|
||||||
|
if [ -n "${command}" ]; then
|
||||||
|
local function
|
||||||
|
# find the matching function
|
||||||
|
function="$(rwx_code_alias_function "${command}")"
|
||||||
|
if [ -n "${function}" ]; then
|
||||||
|
"${function}" "${@}"
|
||||||
|
fi
|
||||||
|
# context / shell
|
||||||
|
else
|
||||||
|
rwx_self_init
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
37
sh/main.sh
37
sh/main.sh
|
@ -3,15 +3,6 @@
|
||||||
# │ main │
|
# │ main │
|
||||||
# ╰──────╯
|
# ╰──────╯
|
||||||
# main module
|
# main module
|
||||||
# * builtins
|
|
||||||
# * echo
|
|
||||||
# * printf
|
|
||||||
# * read
|
|
||||||
# * binaries
|
|
||||||
# * awk
|
|
||||||
# * cat
|
|
||||||
# * find
|
|
||||||
# * sed
|
|
||||||
|
|
||||||
# ╭──────┬───────────╮
|
# ╭──────┬───────────╮
|
||||||
# │ main │ constants │
|
# │ main │ constants │
|
||||||
|
@ -29,6 +20,7 @@ RWX_SELF_NAME="rwx"
|
||||||
# cache of all sourced code modules
|
# cache of all sourced code modules
|
||||||
_rwx_code=""
|
_rwx_code=""
|
||||||
|
|
||||||
|
# TODO variablize
|
||||||
# system root directory of the project
|
# system root directory of the project
|
||||||
RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}"
|
RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}"
|
||||||
# user root directory of the project
|
# user root directory of the project
|
||||||
|
@ -145,6 +137,7 @@ ${text}
|
||||||
# ╰──────┴──────╯
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
# run initial steps
|
# run initial steps
|
||||||
|
#< code
|
||||||
rwx_main() {
|
rwx_main() {
|
||||||
# cache main
|
# cache main
|
||||||
rwx_cache "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"
|
rwx_cache "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"
|
||||||
|
@ -153,30 +146,8 @@ rwx_main() {
|
||||||
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
|
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# source user root
|
# run code main function
|
||||||
rwx_source "${RWX_SELF_USER}"
|
rwx_code_main
|
||||||
# load code cache
|
|
||||||
rwx_code_load
|
|
||||||
# context / 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
|
|
||||||
if [ -n "${command}" ]; then
|
|
||||||
local function
|
|
||||||
# find the matching function
|
|
||||||
function="$(rwx_code_alias_function "${command}")"
|
|
||||||
if [ -n "${function}" ]; then
|
|
||||||
"${function}" "${@}"
|
|
||||||
fi
|
|
||||||
# context / shell
|
|
||||||
else
|
|
||||||
rwx_self_init
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ╭──────┬─────╮
|
# ╭──────┬─────╮
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue