diff --git a/readme.md b/readme.md index 532211c..db7e87d 100644 --- a/readme.md +++ b/readme.md @@ -117,5 +117,6 @@ Two interpreted languages for flexibility. * get unresolved path for new panes & windows * fully working doc function algorithm * self install aliases +* list aliases ### 6.2 [Further tasks](#when) {#when-further} diff --git a/sh/main.awk b/sh/code.awk similarity index 100% rename from sh/main.awk rename to sh/code.awk diff --git a/sh/code.sh b/sh/code.sh new file mode 100644 index 0000000..2c4c5ed --- /dev/null +++ b/sh/code.sh @@ -0,0 +1,70 @@ +# ╭──────╮ +# │ 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}" +} diff --git a/sh/log/log.sh b/sh/log/log.sh index a7bb0f4..a3013e8 100644 --- a/sh/log/log.sh +++ b/sh/log/log.sh @@ -23,6 +23,8 @@ RWX_LOG_LEVEL=${RWX_LOG_LEVEL_INFO} # │ log │ log │ # ╰─────┴─────╯ +rwx_log() { rwx_log_info "${@}"; } + rwx_log_debug() { if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_DEBUG}" ]; then _rwx_log "[DEBUG]" "${@}" @@ -49,7 +51,6 @@ rwx_log_fatal() { fi } -#= rwx_log rwx_log_info() { if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_INFO}" ]; then _rwx_log "" "${@}" diff --git a/sh/main.sh b/sh/main.sh index 22344e8..f1be786 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -3,6 +3,15 @@ # │ main │ # ╰──────╯ # main module +# * builtins +# * echo +# * printf +# * read +# * binaries +# * awk +# * cat +# * find +# * sed # ╭──────┬───────────╮ # │ main │ constants │ @@ -36,8 +45,6 @@ RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" # user root directory of the project RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" -# path to the required parsing awk script -RWX_AWK="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME%.sh}.awk" # path to the entrypoint main file of the project RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" @@ -195,28 +202,28 @@ ${RWX_REGEX_BEGIN}\\(${RWX_REGEX_VARIABLE}\\)${RWX_REGEX_SET}" _rwx_code_variables="" rwx_parse_code() { - # parse aliases + # parse aliases commands local line text - RWX_ALIASES="$(rwx_parse_aliases)" + _rwx_code_aliases_functions="$(rwx_parse_aliases_functions)" while IFS= read -r line; do text="$(echo "${line}" | sed "s| |() { |")" text="${text} \"\${@}\"; }" eval "${text}" done <