self/init
All checks were successful
/ job (push) Successful in 1m15s

This commit is contained in:
Marc Beninca 2024-12-02 15:24:27 +01:00
parent 1eb130320e
commit 01e6165788
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
2 changed files with 44 additions and 12 deletions

View file

@ -136,18 +136,7 @@ rwx_main() {
"${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}" "${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}"
# context / shell # context / shell
else else
# run interactive extras rwx_self_init
if rwx_shell_interactive; then
# check format
rwx_log
rwx_shfmt "${RWX_ROOT_SYSTEM}"
# check syntax
rwx_log
rwx_shellcheck "${RWX_ROOT_SYSTEM}"
# help
rwx_log
rwx_self_help
fi
fi fi
} }

View file

@ -1,3 +1,7 @@
# ╭──────┬──────────╮
# │ self │ commands │
# ╰──────┴──────────╯
# get commands from root # get commands from root
rwx_self_commands() { rwx_self_commands() {
grep \ grep \
@ -8,6 +12,10 @@ rwx_self_commands() {
sed "s|^${RWX_SELF_COMMAND}||" sed "s|^${RWX_SELF_COMMAND}||"
} }
# ╭──────┬───────────╮
# │ self │ functions │
# ╰──────┴───────────╯
# get functions from root # get functions from root
rwx_self_functions() { rwx_self_functions() {
grep \ grep \
@ -17,6 +25,10 @@ rwx_self_functions() {
cut --delimiter "(" --fields 1 cut --delimiter "(" --fields 1
} }
# ╭──────┬──────╮
# │ self │ help │
# ╰──────┴──────╯
# output help message # output help message
rwx_self_help() { rwx_self_help() {
rwx_log \ rwx_log \
@ -25,6 +37,29 @@ rwx_self_help() {
" u__… = user" " u__… = user"
} }
# ╭──────┬──────╮
# │ self │ init │
# ╰──────┴──────╯
rwx_self_init() {
# run interactive extras
if rwx_shell_interactive; then
# check format
rwx_log
rwx_shfmt "${RWX_ROOT_SYSTEM}"
# check syntax
rwx_log
rwx_shellcheck "${RWX_ROOT_SYSTEM}"
# help
rwx_log
rwx_self_help
fi
}
# ╭──────┬─────────╮
# │ self │ install │
# ╰──────┴─────────╯
_rwx_cmd_rwx_install() { rwx_self_install "${@}"; } _rwx_cmd_rwx_install() { rwx_self_install "${@}"; }
rwx_self_install() { rwx_self_install() {
local target="${1}" local target="${1}"
@ -46,6 +81,10 @@ rwx_self_install() {
rwx_link "${file}" "${RWX_MAIN_PATH}" rwx_link "${file}" "${RWX_MAIN_PATH}"
} }
# ╭──────┬────────╮
# │ self │ subset │
# ╰──────┴────────╯
rwx_self_subset() { rwx_self_subset() {
local argument path local argument path
for argument in "${@}"; do for argument in "${@}"; do
@ -61,6 +100,10 @@ rwx_self_subset() {
done done
} }
# ╭──────┬───────╮
# │ self │ write │
# ╰──────┴───────╯
rwx_self_write() { rwx_self_write() {
local target="${1}" local target="${1}"
if [ -n "${target}" ]; then if [ -n "${target}" ]; then