Compare commits
20 commits
58b0919a7c
...
2f7dd63c74
Author | SHA1 | Date | |
---|---|---|---|
2f7dd63c74 | |||
be43cb7fe1 | |||
a41d436657 | |||
2a31766869 | |||
98a46e246e | |||
76e222c60d | |||
77cb7d2bb1 | |||
060a84abda | |||
e157a1ecf7 | |||
7d400d9031 | |||
fed8a38bc1 | |||
a40f086d10 | |||
4a2a24a1b6 | |||
d7bdca5f12 | |||
abca96719b | |||
6b7598eb60 | |||
1dd525b86c | |||
8a6c02a262 | |||
4c5ac91ac3 | |||
b47e6ec7de |
7 changed files with 144 additions and 104 deletions
|
@ -117,5 +117,6 @@ Two interpreted languages for flexibility.
|
||||||
* get unresolved path for new panes & windows
|
* get unresolved path for new panes & windows
|
||||||
* fully working doc function algorithm
|
* fully working doc function algorithm
|
||||||
* self install aliases
|
* self install aliases
|
||||||
|
* list aliases
|
||||||
|
|
||||||
### 6.2 [Further tasks](#when) {#when-further}
|
### 6.2 [Further tasks](#when) {#when-further}
|
||||||
|
|
70
sh/code.sh
Normal file
70
sh/code.sh
Normal file
|
@ -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}"
|
||||||
|
}
|
|
@ -23,6 +23,8 @@ RWX_LOG_LEVEL=${RWX_LOG_LEVEL_INFO}
|
||||||
# │ log │ log │
|
# │ log │ log │
|
||||||
# ╰─────┴─────╯
|
# ╰─────┴─────╯
|
||||||
|
|
||||||
|
rwx_log() { rwx_log_info "${@}"; }
|
||||||
|
|
||||||
rwx_log_debug() {
|
rwx_log_debug() {
|
||||||
if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_DEBUG}" ]; then
|
if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_DEBUG}" ]; then
|
||||||
_rwx_log "[DEBUG]" "${@}"
|
_rwx_log "[DEBUG]" "${@}"
|
||||||
|
@ -49,7 +51,6 @@ rwx_log_fatal() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#= rwx_log
|
|
||||||
rwx_log_info() {
|
rwx_log_info() {
|
||||||
if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_INFO}" ]; then
|
if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_INFO}" ]; then
|
||||||
_rwx_log "" "${@}"
|
_rwx_log "" "${@}"
|
||||||
|
|
50
sh/main.sh
50
sh/main.sh
|
@ -3,6 +3,15 @@
|
||||||
# │ main │
|
# │ main │
|
||||||
# ╰──────╯
|
# ╰──────╯
|
||||||
# main module
|
# main module
|
||||||
|
# * builtins
|
||||||
|
# * echo
|
||||||
|
# * printf
|
||||||
|
# * read
|
||||||
|
# * binaries
|
||||||
|
# * awk
|
||||||
|
# * cat
|
||||||
|
# * find
|
||||||
|
# * sed
|
||||||
|
|
||||||
# ╭──────┬───────────╮
|
# ╭──────┬───────────╮
|
||||||
# │ main │ constants │
|
# │ main │ constants │
|
||||||
|
@ -36,8 +45,6 @@ RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}"
|
||||||
# user root directory of the project
|
# user root directory of the project
|
||||||
RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}"
|
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
|
# path to the entrypoint main file of the project
|
||||||
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
|
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_code_variables=""
|
||||||
|
|
||||||
rwx_parse_code() {
|
rwx_parse_code() {
|
||||||
# parse aliases
|
# parse aliases commands
|
||||||
local line text
|
local line text
|
||||||
RWX_ALIASES="$(rwx_parse_aliases)"
|
_rwx_code_aliases_functions="$(rwx_parse_aliases_functions)"
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
text="$(echo "${line}" | sed "s| |() { |")"
|
text="$(echo "${line}" | sed "s| |() { |")"
|
||||||
text="${text} \"\${@}\"; }"
|
text="${text} \"\${@}\"; }"
|
||||||
eval "${text}"
|
eval "${text}"
|
||||||
done <<EOF
|
done <<EOF
|
||||||
${RWX_ALIASES}
|
${_rwx_code_aliases_functions}
|
||||||
EOF
|
EOF
|
||||||
# parse constants
|
# parse constants
|
||||||
RWX_CONSTANTS="$(rwx_parse_constants)"
|
_rwx_code_constants="$(rwx_parse_constants)"
|
||||||
# parse functions
|
# parse functions
|
||||||
RWX_FUNCTIONS="$(rwx_parse_functions)"
|
_rwx_code_functions="$(rwx_parse_functions)"
|
||||||
# parse variables
|
# parse variables
|
||||||
_rwx_code_variables="$(rwx_parse_variables)"
|
_rwx_code_variables="$(rwx_parse_variables)"
|
||||||
}
|
}
|
||||||
rwx_parse_aliases() {
|
rwx_parse_aliases_functions() {
|
||||||
printf "%s" "${_rwx_code}" |
|
printf "%s" "${_rwx_code}" |
|
||||||
awk \
|
awk \
|
||||||
--assign action="alias" \
|
--assign action="alias" \
|
||||||
--file "${RWX_AWK}"
|
"${_rwx_code_awk}"
|
||||||
}
|
}
|
||||||
rwx_parse_constants() {
|
rwx_parse_constants() {
|
||||||
printf "%s" "${_rwx_code}" |
|
printf "%s" "${_rwx_code}" |
|
||||||
|
@ -231,31 +238,6 @@ rwx_parse_variables() {
|
||||||
sed --silent "s|${RWX_REGEX_TARGET_VARIABLE}|\\1|p"
|
sed --silent "s|${RWX_REGEX_TARGET_VARIABLE}|\\1|p"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ╭──────┬──────╮
|
|
||||||
# │ main │ test │
|
|
||||||
# ╰──────┴──────╯
|
|
||||||
|
|
||||||
#= rt
|
|
||||||
rwx_test() {
|
|
||||||
local item
|
|
||||||
set \
|
|
||||||
"main" \
|
|
||||||
"alias/git" \
|
|
||||||
\
|
|
||||||
"RWX_MAIN_NAME" \
|
|
||||||
\
|
|
||||||
"_rwx_code" \
|
|
||||||
\
|
|
||||||
"rwx_cache" \
|
|
||||||
\
|
|
||||||
"alias/batcat" \
|
|
||||||
"b"
|
|
||||||
for item in "${@}"; do
|
|
||||||
echo
|
|
||||||
rwx_doc "${item}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# ╭──────┬─────╮
|
# ╭──────┬─────╮
|
||||||
# │ main │ run │
|
# │ main │ run │
|
||||||
# ╰──────┴─────╯
|
# ╰──────┴─────╯
|
||||||
|
|
69
sh/self.sh
69
sh/self.sh
|
@ -1,62 +1,6 @@
|
||||||
# self
|
# self
|
||||||
# module
|
# module
|
||||||
|
|
||||||
# show the cached code
|
|
||||||
#= rc
|
|
||||||
rwx_code() {
|
|
||||||
echo "${_rwx_code}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# show the cached aliases
|
|
||||||
#= rca
|
|
||||||
rwx_code_aliases() {
|
|
||||||
echo "${RWX_ALIASES}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# show the cached constants
|
|
||||||
#= rcc
|
|
||||||
rwx_code_constants() {
|
|
||||||
echo "${RWX_CONSTANTS}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# show the cached functions
|
|
||||||
#= rcf
|
|
||||||
rwx_code_functions() {
|
|
||||||
echo "${RWX_FUNCTIONS}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# show the cached variables
|
|
||||||
#= rcv
|
|
||||||
rwx_code_variables() {
|
|
||||||
echo "${_rwx_code_variables}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# meta doc
|
|
||||||
#= rd
|
|
||||||
rwx_doc() {
|
|
||||||
local name="${1}"
|
|
||||||
[ -n "${name}" ] || return
|
|
||||||
printf "%s" "${_rwx_code}" |
|
|
||||||
awk \
|
|
||||||
--assign action="doc" \
|
|
||||||
--assign target="${name}" \
|
|
||||||
--file "${RWX_AWK}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ╭──────┬───────╮
|
|
||||||
# │ self │ check │
|
|
||||||
# ╰──────┴───────╯
|
|
||||||
|
|
||||||
# check source code
|
|
||||||
rwx_self_check() {
|
|
||||||
# check format
|
|
||||||
rwx_log
|
|
||||||
rwx_shfmt "${RWX_ROOT_SYSTEM}"
|
|
||||||
# check syntax
|
|
||||||
rwx_log
|
|
||||||
rwx_shellcheck "${RWX_ROOT_SYSTEM}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ╭──────┬──────────╮
|
# ╭──────┬──────────╮
|
||||||
# │ self │ commands │
|
# │ self │ commands │
|
||||||
# ╰──────┴──────────╯
|
# ╰──────┴──────────╯
|
||||||
|
@ -71,19 +15,6 @@ rwx_self_commands() {
|
||||||
sed "s|^${RWX_SELF_COMMAND}||"
|
sed "s|^${RWX_SELF_COMMAND}||"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ╭──────┬───────────╮
|
|
||||||
# │ self │ functions │
|
|
||||||
# ╰──────┴───────────╯
|
|
||||||
|
|
||||||
# get functions from root
|
|
||||||
rwx_self_functions() {
|
|
||||||
grep \
|
|
||||||
--directories "recurse" \
|
|
||||||
--no-filename \
|
|
||||||
"()" "${RWX_ROOT_SYSTEM}" |
|
|
||||||
cut --delimiter "(" --fields 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# ╭──────┬──────╮
|
# ╭──────┬──────╮
|
||||||
# │ self │ help │
|
# │ self │ help │
|
||||||
# ╰──────┴──────╯
|
# ╰──────┴──────╯
|
||||||
|
|
55
sh/test.sh
Normal file
55
sh/test.sh
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# ╭──────╮
|
||||||
|
# │ test │
|
||||||
|
# ╰──────╯
|
||||||
|
# * code
|
||||||
|
# * doc
|
||||||
|
|
||||||
|
rwx_test() {
|
||||||
|
rwx_test_code
|
||||||
|
rwx_test_doc
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────┬──────╮
|
||||||
|
# │ test │ code │
|
||||||
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
|
rwx_test_code() {
|
||||||
|
local items
|
||||||
|
set \
|
||||||
|
"constants" \
|
||||||
|
"variables" \
|
||||||
|
"functions" \
|
||||||
|
"aliases_functions" \
|
||||||
|
"aliases" \
|
||||||
|
|
||||||
|
rwx_code
|
||||||
|
for items in "${@}"; do
|
||||||
|
echo
|
||||||
|
"rwx_code_${items}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────┬─────╮
|
||||||
|
# │ test │ doc │
|
||||||
|
# ╰──────┴─────╯
|
||||||
|
|
||||||
|
rwx_test_doc() {
|
||||||
|
local item
|
||||||
|
set \
|
||||||
|
"main" \
|
||||||
|
"alias/git" \
|
||||||
|
\
|
||||||
|
"RWX_MAIN_NAME" \
|
||||||
|
\
|
||||||
|
"_rwx_code" \
|
||||||
|
\
|
||||||
|
"rwx_cache" \
|
||||||
|
\
|
||||||
|
"alias/batcat" \
|
||||||
|
"b" \
|
||||||
|
|
||||||
|
for item in "${@}"; do
|
||||||
|
echo
|
||||||
|
rwx_code_doc "${item}"
|
||||||
|
done
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue