code/load
This commit is contained in:
parent
45f0ebbb9b
commit
0b12a7545e
2 changed files with 53 additions and 57 deletions
51
sh/code.sh
51
sh/code.sh
|
@ -89,3 +89,54 @@ rwx_code_doc() {
|
||||||
--assign target="${name}" \
|
--assign target="${name}" \
|
||||||
"${_rwx_code_awk}"
|
"${_rwx_code_awk}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rwx_code_load() {
|
||||||
|
# parse aliases
|
||||||
|
_rwx_code_aliases="$(rwx_parse_aliases)"
|
||||||
|
# parse aliases functions
|
||||||
|
local line text
|
||||||
|
_rwx_code_aliases_functions="$(rwx_parse_aliases_functions)"
|
||||||
|
while IFS= read -r line; do
|
||||||
|
text="$(echo "${line}" | sed "s| |() { |")"
|
||||||
|
text="${text} \"\${@}\"; }"
|
||||||
|
eval "${text}"
|
||||||
|
done <<EOF
|
||||||
|
${_rwx_code_aliases_functions}
|
||||||
|
EOF
|
||||||
|
# parse constants
|
||||||
|
_rwx_code_constants="$(rwx_parse_constants)"
|
||||||
|
# parse functions
|
||||||
|
_rwx_code_functions="$(rwx_parse_functions)"
|
||||||
|
# parse variables
|
||||||
|
_rwx_code_variables="$(rwx_parse_variables)"
|
||||||
|
}
|
||||||
|
rwx_parse_aliases() {
|
||||||
|
rwx_code |
|
||||||
|
awk \
|
||||||
|
--assign action="aliases" \
|
||||||
|
"${_rwx_code_awk}"
|
||||||
|
}
|
||||||
|
rwx_parse_aliases_functions() {
|
||||||
|
rwx_code |
|
||||||
|
awk \
|
||||||
|
--assign action="aliases functions" \
|
||||||
|
"${_rwx_code_awk}"
|
||||||
|
}
|
||||||
|
rwx_parse_constants() {
|
||||||
|
rwx_code |
|
||||||
|
awk \
|
||||||
|
--assign action="constants" \
|
||||||
|
"${_rwx_code_awk}"
|
||||||
|
}
|
||||||
|
rwx_parse_functions() {
|
||||||
|
rwx_code |
|
||||||
|
awk \
|
||||||
|
--assign action="functions" \
|
||||||
|
"${_rwx_code_awk}"
|
||||||
|
}
|
||||||
|
rwx_parse_variables() {
|
||||||
|
rwx_code |
|
||||||
|
awk \
|
||||||
|
--assign action="variables" \
|
||||||
|
"${_rwx_code_awk}"
|
||||||
|
}
|
||||||
|
|
59
sh/main.sh
59
sh/main.sh
|
@ -63,8 +63,8 @@ rwx_main() {
|
||||||
fi
|
fi
|
||||||
# source user root
|
# source user root
|
||||||
rwx_source "${RWX_SELF_USER}"
|
rwx_source "${RWX_SELF_USER}"
|
||||||
# parse code cache
|
# load code cache
|
||||||
rwx_parse_code
|
rwx_code_load
|
||||||
# context / command
|
# context / command
|
||||||
if [ -n "${RWX_COMMAND_NAME}" ]; then
|
if [ -n "${RWX_COMMAND_NAME}" ]; then
|
||||||
"${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}"
|
"${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}"
|
||||||
|
@ -177,61 +177,6 @@ rwx_find_shell() {
|
||||||
rwx_find_extension "sh" "${@}"
|
rwx_find_extension "sh" "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ╭──────┬───────╮
|
|
||||||
# │ main │ parse │
|
|
||||||
# ╰──────┴───────╯
|
|
||||||
|
|
||||||
rwx_parse_code() {
|
|
||||||
# parse aliases
|
|
||||||
_rwx_code_aliases="$(rwx_parse_aliases)"
|
|
||||||
# parse aliases functions
|
|
||||||
local line text
|
|
||||||
_rwx_code_aliases_functions="$(rwx_parse_aliases_functions)"
|
|
||||||
while IFS= read -r line; do
|
|
||||||
text="$(echo "${line}" | sed "s| |() { |")"
|
|
||||||
text="${text} \"\${@}\"; }"
|
|
||||||
eval "${text}"
|
|
||||||
done <<EOF
|
|
||||||
${_rwx_code_aliases_functions}
|
|
||||||
EOF
|
|
||||||
# parse constants
|
|
||||||
_rwx_code_constants="$(rwx_parse_constants)"
|
|
||||||
# parse functions
|
|
||||||
_rwx_code_functions="$(rwx_parse_functions)"
|
|
||||||
# parse variables
|
|
||||||
_rwx_code_variables="$(rwx_parse_variables)"
|
|
||||||
}
|
|
||||||
rwx_parse_aliases() {
|
|
||||||
rwx_code |
|
|
||||||
awk \
|
|
||||||
--assign action="aliases" \
|
|
||||||
"${_rwx_code_awk}"
|
|
||||||
}
|
|
||||||
rwx_parse_aliases_functions() {
|
|
||||||
rwx_code |
|
|
||||||
awk \
|
|
||||||
--assign action="aliases functions" \
|
|
||||||
"${_rwx_code_awk}"
|
|
||||||
}
|
|
||||||
rwx_parse_constants() {
|
|
||||||
rwx_code |
|
|
||||||
awk \
|
|
||||||
--assign action="constants" \
|
|
||||||
"${_rwx_code_awk}"
|
|
||||||
}
|
|
||||||
rwx_parse_functions() {
|
|
||||||
rwx_code |
|
|
||||||
awk \
|
|
||||||
--assign action="functions" \
|
|
||||||
"${_rwx_code_awk}"
|
|
||||||
}
|
|
||||||
rwx_parse_variables() {
|
|
||||||
rwx_code |
|
|
||||||
awk \
|
|
||||||
--assign action="variables" \
|
|
||||||
"${_rwx_code_awk}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ╭──────┬─────╮
|
# ╭──────┬─────╮
|
||||||
# │ main │ run │
|
# │ main │ run │
|
||||||
# ╰──────┴─────╯
|
# ╰──────┴─────╯
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue