Compare commits
No commits in common. "31ca2c6117fd9726944205e63f20163b207d570a" and "dfa9fc1a7ac84818f0e723b92e8525db842552b6" have entirely different histories.
31ca2c6117
...
dfa9fc1a7a
3 changed files with 51 additions and 49 deletions
|
@ -1,3 +1,3 @@
|
|||
disable=2312,3043
|
||||
disable=2312
|
||||
enable=all
|
||||
shell=sh
|
||||
|
|
|
@ -225,7 +225,9 @@ Handle project workflows in a unified way:
|
|||
* comment
|
||||
* drawing characters constants
|
||||
* handle errors
|
||||
* local variables
|
||||
* locales
|
||||
* set unicode C
|
||||
* set unicode language
|
||||
* packages
|
||||
* configure
|
||||
* apk
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
# ╰───╯
|
||||
|
||||
_spcd_fill() {
|
||||
local index="${1}"
|
||||
while [ "${index}" -gt 0 ]; do
|
||||
_spcd_fill__index=${1}
|
||||
while [ "${_spcd_fill__index}" -gt 0 ]; do
|
||||
printf "%s" "${2}"
|
||||
index=$((index - 1))
|
||||
_spcd_fill__index=$((_spcd_fill__index - 1))
|
||||
done
|
||||
unset _spcd_fill__index
|
||||
}
|
||||
|
||||
# ╭───┬────────╮
|
||||
|
@ -27,33 +28,35 @@ _SPCD_BANNER_VERTICAL="│"
|
|||
|
||||
_spcd_banner_add() {
|
||||
if [ -n "${1}" ]; then
|
||||
local text=" ${1} "
|
||||
local length=${#text}
|
||||
local filler="$(_spcd_fill "${length}" "${_SPCD_BANNER_HORIZONTAL}")"
|
||||
spcd_ba__text=" ${1} "
|
||||
spcd_ba__length=${#spcd_ba__text}
|
||||
spcd_ba__filler="$(
|
||||
_spcd_fill "${spcd_ba__length}" "${_SPCD_BANNER_HORIZONTAL}"
|
||||
)"
|
||||
if [ -n "${__SPCD_BANNER_MIDDLE}" ]; then
|
||||
_spcd_banner_split
|
||||
else
|
||||
_spcd_banner_open
|
||||
fi
|
||||
_spcd_banner_append "${filler}" "${text}" "${filler}"
|
||||
_spcd_banner_append \
|
||||
"${spcd_ba__filler}" "${spcd_ba__text}" "${spcd_ba__filler}"
|
||||
fi
|
||||
}
|
||||
|
||||
_spcd_banner_add_index() {
|
||||
local label
|
||||
local level
|
||||
local value
|
||||
unset spcd_bai__label
|
||||
unset spcd_bai__level
|
||||
while true; do
|
||||
level=$((level + 1))
|
||||
eval "value=\"\${__SPCD_STEP_${level}_INDEX}\""
|
||||
[ -n "${value}" ] || break
|
||||
if [ -n "${label}" ]; then
|
||||
label="${label}.${value}"
|
||||
spcd_bai__level=$((spcd_bai__level + 1))
|
||||
eval "spcd_bai__value=\"\${__SPCD_STEP_${spcd_bai__level}_INDEX}\""
|
||||
[ -n "${spcd_bai__value}" ] || break
|
||||
if [ -n "${spcd_bai__label}" ]; then
|
||||
spcd_bai__label="${spcd_bai__label}.${spcd_bai__value}"
|
||||
else
|
||||
label="${value}"
|
||||
spcd_bai__label="${spcd_bai__value}"
|
||||
fi
|
||||
done
|
||||
_spcd_banner_add "${label}"
|
||||
_spcd_banner_add "${spcd_bai__label}"
|
||||
}
|
||||
|
||||
_spcd_banner_append() {
|
||||
|
@ -83,13 +86,12 @@ _spcd_banner_render() {
|
|||
_spcd_banner_add "S"
|
||||
_spcd_banner_add_index
|
||||
#
|
||||
local level
|
||||
local value
|
||||
unset spcd_br__level
|
||||
while true; do
|
||||
level=$((level + 1))
|
||||
eval "value=\"\${__SPCD_STEP_${level}_LABEL}\""
|
||||
[ -n "${value}" ] || break
|
||||
_spcd_banner_add "${value}"
|
||||
spcd_br__level=$((spcd_br__level + 1))
|
||||
eval "spcd_br__value=\"\${__SPCD_STEP_${spcd_br__level}_LABEL}\""
|
||||
[ -n "${spcd_br__value}" ] || break
|
||||
_spcd_banner_add "${spcd_br__value}"
|
||||
done
|
||||
#
|
||||
_spcd_banner_shut
|
||||
|
@ -221,10 +223,10 @@ spcd_openssl_x509() {
|
|||
# ╰───────────┴────╯
|
||||
|
||||
spcd_os_grep() {
|
||||
local variable="${1}"
|
||||
[ -n "${variable}" ] &&
|
||||
grep "^${variable}=" "/etc/os-release" |
|
||||
sed "s|^${variable}=||" |
|
||||
spcd_os_grep__variable="${1}"
|
||||
[ -n "${spcd_os_grep__variable}" ] &&
|
||||
grep "^${spcd_os_grep__variable}=" "/etc/os-release" |
|
||||
sed "s|^${spcd_os_grep__variable}=||" |
|
||||
sed "s|^\"\(.*\)\"$|\1|"
|
||||
}
|
||||
|
||||
|
@ -243,11 +245,10 @@ spcd_os_mkdir() {
|
|||
|
||||
spcd_os_printenv() {
|
||||
if [ -n "${1}" ]; then
|
||||
local name
|
||||
local text
|
||||
for name in "${@}"; do
|
||||
eval "text=\"\${${name}}\""
|
||||
echo "${name} = \"${text}\""
|
||||
for spcd_os_printenv__name in "${@}"; do
|
||||
spcd_os_printenv__text=""
|
||||
eval "spcd_os_printenv__text=\"\${${spcd_os_printenv__name}}\""
|
||||
echo "${spcd_os_printenv__name} = \"${spcd_os_printenv__text}\""
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
@ -260,27 +261,26 @@ spcd_os_rm() {
|
|||
}
|
||||
|
||||
spcd_os_sed() {
|
||||
local file="${1}"
|
||||
spcd_os_sed__file="${1}"
|
||||
shift
|
||||
if [ -f "${file}" ]; then
|
||||
local regex
|
||||
_spcd_os_cat "${file}"
|
||||
for regex in "${@}"; do
|
||||
sed --in-place "s${regex}g" "${file}" &&
|
||||
_spcd_os_cat "${file}"
|
||||
if [ -f "${spcd_os_sed__file}" ]; then
|
||||
_spcd_os_cat "${spcd_os_sed__file}"
|
||||
for spcd_os_sed__regex in "${@}"; do
|
||||
sed --in-place "s${spcd_os_sed__regex}g" "${spcd_os_sed__file}" &&
|
||||
_spcd_os_cat "${spcd_os_sed__file}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_os_write() {
|
||||
local file="${1}"
|
||||
local text="${2}"
|
||||
if [ -n "${file}" ]; then
|
||||
[ -f "${file}" ] &&
|
||||
_spcd_os_cat "${file}"
|
||||
echo "→ ${file}"
|
||||
printf "%s" "${text}" >"${file}"
|
||||
_spcd_os_cat "${file}"
|
||||
spcd_os_write__file="${1}"
|
||||
spcd_os_write__text="${2}"
|
||||
if [ -n "${spcd_os_write__file}" ]; then
|
||||
[ -f "${spcd_os_write__file}" ] &&
|
||||
_spcd_os_cat "${spcd_os_write__file}"
|
||||
echo "→ ${spcd_os_write__file}"
|
||||
printf "%s" "${spcd_os_write__text}" >"${spcd_os_write__file}"
|
||||
_spcd_os_cat "${spcd_os_write__file}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue