self/functions
This commit is contained in:
parent
245aa85f29
commit
5fc07cfbc1
2 changed files with 11 additions and 18 deletions
19
sh/main.sh
19
sh/main.sh
|
@ -16,17 +16,6 @@ RWX_SYSTEM_ROOT="/usr/local/lib"
|
||||||
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
|
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
|
||||||
RWX_ROOT_SYSTEM="${RWX_SYSTEM_ROOT}/${RWX_SELF_NAME}"
|
RWX_ROOT_SYSTEM="${RWX_SYSTEM_ROOT}/${RWX_SELF_NAME}"
|
||||||
|
|
||||||
# ╭────────╮
|
|
||||||
# │ public │
|
|
||||||
# ╰────────╯
|
|
||||||
|
|
||||||
# get functions from file
|
|
||||||
rwx_grep_functions() {
|
|
||||||
local file="${1}"
|
|
||||||
grep "()" "${file}" |
|
|
||||||
cut --delimiter "(" --fields 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# ╭──────╮
|
# ╭──────╮
|
||||||
# │ core │
|
# │ core │
|
||||||
# ╰──────╯
|
# ╰──────╯
|
||||||
|
@ -103,7 +92,7 @@ rwx_source() {
|
||||||
local path="${1}"
|
local path="${1}"
|
||||||
[ -d "${path}" ] ||
|
[ -d "${path}" ] ||
|
||||||
return 1
|
return 1
|
||||||
local cmd count module modules
|
local count module modules
|
||||||
modules="$(rwx_find_shell "${path}" "${RWX_MAIN_NAME}")"
|
modules="$(rwx_find_shell "${path}" "${RWX_MAIN_NAME}")"
|
||||||
rwx_ifs_set
|
rwx_ifs_set
|
||||||
count=0
|
count=0
|
||||||
|
@ -115,12 +104,6 @@ rwx_source() {
|
||||||
module="${path}/${module}"
|
module="${path}/${module}"
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
. "${module}"
|
. "${module}"
|
||||||
cmd="$(rwx_grep_functions "${module}")"
|
|
||||||
if [ -n "${cmd}" ]; then
|
|
||||||
[ -n "${CMD}" ] && CMD="${CMD}
|
|
||||||
"
|
|
||||||
CMD="${CMD}${cmd}"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
rwx_ifs_unset
|
rwx_ifs_unset
|
||||||
}
|
}
|
||||||
|
|
10
sh/self.sh
10
sh/self.sh
|
@ -1,3 +1,13 @@
|
||||||
|
# get functions from file
|
||||||
|
rwx_self_functions() {
|
||||||
|
local file="${1}"
|
||||||
|
grep \
|
||||||
|
--directories "recurse" \
|
||||||
|
--no-filename \
|
||||||
|
"()" "${RWX_ROOT_SYSTEM}" |
|
||||||
|
cut --delimiter "(" --fields 1
|
||||||
|
}
|
||||||
|
|
||||||
# output help message
|
# output help message
|
||||||
rwx_self_help() {
|
rwx_self_help() {
|
||||||
rwx_log \
|
rwx_log \
|
||||||
|
|
Loading…
Add table
Reference in a new issue