code/commands
This commit is contained in:
parent
51cb88d0d3
commit
cc1f8f816a
2 changed files with 21 additions and 2 deletions
10
sh/code.awk
10
sh/code.awk
|
@ -32,6 +32,7 @@ BEGIN {
|
||||||
|
|
||||||
RE_ALIAS = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END
|
RE_ALIAS = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END
|
||||||
RE_CLOSE = RE_BEGIN "}" RE_SPACES RE_END
|
RE_CLOSE = RE_BEGIN "}" RE_SPACES RE_END
|
||||||
|
RE_COMMAND = RE_BEGIN "#/" RE_SPACES RE_VAR RE_END
|
||||||
RE_CONSTANT = RE_BEGIN RE_CONST RE_SET RE_END
|
RE_CONSTANT = RE_BEGIN RE_CONST RE_SET RE_END
|
||||||
RE_DOC = RE_BEGIN RE_SPACES "#" RE_SPACE RE_ANY RE_END
|
RE_DOC = RE_BEGIN RE_SPACES "#" RE_SPACE RE_ANY RE_END
|
||||||
RE_FUNCTION = RE_BEGIN RE_VAR RE_FUNC RE_END
|
RE_FUNCTION = RE_BEGIN RE_VAR RE_FUNC RE_END
|
||||||
|
@ -50,6 +51,10 @@ BEGIN {
|
||||||
if (match($0, RE_ALIAS, m)) {
|
if (match($0, RE_ALIAS, m)) {
|
||||||
print m[1]
|
print m[1]
|
||||||
}
|
}
|
||||||
|
} else if (action == "commands") {
|
||||||
|
if (match($0, RE_COMMAND, m)) {
|
||||||
|
print m[1]
|
||||||
|
}
|
||||||
} else if (action == "constants") {
|
} else if (action == "constants") {
|
||||||
if (match($0, RE_CONSTANT, m)) {
|
if (match($0, RE_CONSTANT, m)) {
|
||||||
print m[1]
|
print m[1]
|
||||||
|
@ -89,6 +94,11 @@ BEGIN {
|
||||||
if (m[1] == target) {
|
if (m[1] == target) {
|
||||||
alias = 1
|
alias = 1
|
||||||
}
|
}
|
||||||
|
} else if (match($0, RE_COMMAND, m)) {
|
||||||
|
append("/ " m[1])
|
||||||
|
if (m[1] == target) {
|
||||||
|
alias = 1
|
||||||
|
}
|
||||||
# set
|
# set
|
||||||
} else if (match($0, RE_CONSTANT, m)) {
|
} else if (match($0, RE_CONSTANT, m)) {
|
||||||
if (m[1] == target) {
|
if (m[1] == target) {
|
||||||
|
|
13
sh/code.sh
13
sh/code.sh
|
@ -12,6 +12,8 @@ _rwx_code_awk="$(cat "${RWX_ROOT_SYSTEM}/code.awk")"
|
||||||
_rwx_code_aliases=""
|
_rwx_code_aliases=""
|
||||||
# cache for code aliases functions
|
# cache for code aliases functions
|
||||||
_rwx_code_aliases_functions=""
|
_rwx_code_aliases_functions=""
|
||||||
|
# cache for code commands
|
||||||
|
_rwx_code_commands=""
|
||||||
# cache for code constants
|
# cache for code constants
|
||||||
_rwx_code_constants=""
|
_rwx_code_constants=""
|
||||||
# cache for code functions
|
# cache for code functions
|
||||||
|
@ -23,7 +25,7 @@ _rwx_code_variables=""
|
||||||
# │ code │ install │
|
# │ code │ install │
|
||||||
# ╰──────┴─────────╯
|
# ╰──────┴─────────╯
|
||||||
|
|
||||||
#= rwx_install
|
#/ rwx_install
|
||||||
rwx_code_install() {
|
rwx_code_install() {
|
||||||
local target="${1}"
|
local target="${1}"
|
||||||
local command file name root
|
local command file name root
|
||||||
|
@ -44,7 +46,7 @@ rwx_code_install() {
|
||||||
rwx_remove "${file}"
|
rwx_remove "${file}"
|
||||||
rwx_link "${file}" "${name}"
|
rwx_link "${file}" "${name}"
|
||||||
done <<EOF
|
done <<EOF
|
||||||
${_rwx_code_aliases}
|
${_rwx_code_commands}
|
||||||
EOF
|
EOF
|
||||||
# sh
|
# sh
|
||||||
file="${target}/etc/profile.d/${RWX_SELF_NAME}.sh"
|
file="${target}/etc/profile.d/${RWX_SELF_NAME}.sh"
|
||||||
|
@ -100,6 +102,11 @@ rwx_code_aliases_functions() {
|
||||||
echo "${_rwx_code_aliases_functions}"
|
echo "${_rwx_code_aliases_functions}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# show the cached commands
|
||||||
|
rwx_code_commands() {
|
||||||
|
echo "${_rwx_code_commands}"
|
||||||
|
}
|
||||||
|
|
||||||
# show the cached constants
|
# show the cached constants
|
||||||
#= rcc
|
#= rcc
|
||||||
rwx_code_constants() {
|
rwx_code_constants() {
|
||||||
|
@ -157,6 +164,8 @@ rwx_code_load() {
|
||||||
done <<EOF
|
done <<EOF
|
||||||
${_rwx_code_aliases_functions}
|
${_rwx_code_aliases_functions}
|
||||||
EOF
|
EOF
|
||||||
|
# parse commands
|
||||||
|
_rwx_code_commands="$(rwx_code_parse "commands")"
|
||||||
# parse constants
|
# parse constants
|
||||||
_rwx_code_constants="$(rwx_code_parse "constants")"
|
_rwx_code_constants="$(rwx_code_parse "constants")"
|
||||||
# parse functions
|
# parse functions
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue