70 lines
1.4 KiB
Bash
70 lines
1.4 KiB
Bash
# ╭──────╮
|
|
# │ code │
|
|
# ╰──────╯
|
|
|
|
# ╭──────┬───────────╮
|
|
# │ code │ variables │
|
|
# ╰──────┴───────────╯
|
|
|
|
# path to the required parsing awk script
|
|
_rwx_code_awk="$(cat "${RWX_ROOT_SYSTEM}/code.awk")"
|
|
|
|
# ╭──────┬───────╮
|
|
# │ code │ parts │
|
|
# ╰──────┴───────╯
|
|
|
|
# show the cached code
|
|
#= rc
|
|
rwx_code() {
|
|
echo "${_rwx_code}"
|
|
}
|
|
|
|
# show the cached aliases and functions
|
|
#= rcaf
|
|
rwx_code_aliases_functions() {
|
|
echo "${_rwx_code_aliases_functions}"
|
|
}
|
|
|
|
# show the cached constants
|
|
#= rcc
|
|
rwx_code_constants() {
|
|
echo "${_rwx_code_constants}"
|
|
}
|
|
|
|
# show the cached functions
|
|
#= rcf
|
|
rwx_code_functions() {
|
|
echo "${_rwx_code_functions}"
|
|
}
|
|
|
|
# show the cached variables
|
|
#= rcv
|
|
rwx_code_variables() {
|
|
echo "${_rwx_code_variables}"
|
|
}
|
|
|
|
# ╭──────┬───────╮
|
|
# │ code │ parse │
|
|
# ╰──────┴───────╯
|
|
|
|
# check source code
|
|
rwx_code_check() {
|
|
# check format
|
|
rwx_log
|
|
rwx_shfmt "${RWX_ROOT_SYSTEM}"
|
|
# check syntax
|
|
rwx_log
|
|
rwx_shellcheck "${RWX_ROOT_SYSTEM}"
|
|
}
|
|
|
|
# fetch matching doc for given name
|
|
#= rcd
|
|
rwx_code_doc() {
|
|
local name="${1}"
|
|
[ -n "${name}" ] || return
|
|
printf "%s" "${_rwx_code}" |
|
|
awk \
|
|
--assign action="doc" \
|
|
--assign target="${name}" \
|
|
"${_rwx_code_awk}"
|
|
}
|