commands/functions

This commit is contained in:
Marc Beninca 2025-07-08 15:48:13 +02:00
parent 0926d058f5
commit 9b61976835
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
3 changed files with 38 additions and 2 deletions

View file

@ -85,6 +85,18 @@ BEGIN {
} else { } else {
reset() reset()
} }
} else if (action == "commands functions") {
if (match($0, RE_COMMAND, m)) {
append(m[1])
} else if (match($0, RE_FUNCTION, m)) {
n = split(doc, array, "\n")
for (i = 1; i<= n; i++) {
print array[i] " " m[1]
}
reset()
} else {
reset()
}
} else if (action == "doc") { } else if (action == "doc") {
# doc # doc
if (match($0, RE_SHEBANG, m)) { if (match($0, RE_SHEBANG, m)) {

View file

@ -22,6 +22,8 @@ _rwx_code_aliases_functions=""
_rwx_code_binaries="" _rwx_code_binaries=""
# cache for code commands # cache for code commands
_rwx_code_commands="" _rwx_code_commands=""
# cache for code commands functions
_rwx_code_commands_functions=""
# cache for code constants # cache for code constants
_rwx_code_constants="" _rwx_code_constants=""
# cache for code functions # cache for code functions
@ -101,7 +103,7 @@ rwx_code_aliases() {
echo "${_rwx_code_aliases}" echo "${_rwx_code_aliases}"
} }
# find aliased function # find alias function
rwx_code_alias_function() { rwx_code_alias_function() {
local target="${1}" local target="${1}"
local line name local line name
@ -116,6 +118,21 @@ ${_rwx_code_aliases_functions}
EOF EOF
} }
# find command function
rwx_code_command_function() {
local target="${1}"
local line name
while IFS= read -r line; do
name="$(echo "${line}" | awk "{print \$1}")"
if [ "${name}" = "${target}" ]; then
echo "${line}" |
awk "{print \$2}"
fi
done <<EOF
${_rwx_code_commands_functions}
EOF
}
# show the cached aliases and functions # show the cached aliases and functions
#= rcaf #= rcaf
rwx_code_aliases_functions() { rwx_code_aliases_functions() {
@ -132,6 +149,12 @@ rwx_code_commands() {
echo "${_rwx_code_commands}" echo "${_rwx_code_commands}"
} }
# show the cached commands and functions
#= rccf
rwx_code_commands_functions() {
echo "${_rwx_code_commands_functions}"
}
# show the cached constants # show the cached constants
#= rcc #= rcc
rwx_code_constants() { rwx_code_constants() {

View file

@ -22,7 +22,8 @@ rwx_test_code() {
"functions" \ "functions" \
"aliases" \ "aliases" \
"aliases_functions" \ "aliases_functions" \
"commands" "commands" \
"commands_functions"
rwx_code rwx_code
for items in "${@}"; do for items in "${@}"; do
echo echo