This commit is contained in:
pika 2025-05-22 16:03:40 +02:00
parent dfe0c9e6c1
commit 4cab6852da

68
test.sh
View file

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
deplist=()
# ─< Check if the given command exists silently >───────────────────────────────────────── # ─< Check if the given command exists silently >─────────────────────────────────────────
command_exists() { command_exists() {
@ -39,7 +40,6 @@ spin-get-dependencies() {
depsAlpine=(bash zsh curl git neofetch waybar wlogout) depsAlpine=(bash zsh curl git neofetch waybar wlogout)
# declare -A deplist # declare -A deplist
deplist=()
declare -A deps=( declare -A deps=(
[debian]="depsDebian" [debian]="depsDebian"
@ -64,8 +64,7 @@ spin-get-dependencies() {
fi fi
done done
check "pkglist: ${pkglist[*]}" check "pkglist: ${deplist[*]}"
line line
# pen red "$deplist" # pen red "$deplist"
@ -75,7 +74,7 @@ spin-get-dependencies() {
# pen bold grey "Dep: $dep" # pen bold grey "Dep: $dep"
# done # done
spin-installation "${deplist[@]}" # spin-installation "${deplist[@]}"
# for pk in "${pkglist[@]}"; do # for pk in "${pkglist[@]}"; do
# pen bold red "Pkg: $pk" # pen bold red "Pkg: $pk"
@ -92,23 +91,23 @@ spin-get-dependencies() {
esac esac
} }
spin-installation() { # spin-installation() {
local err out # local err out
local pkgs="$@" # local pkgs="$@"
#
for pkg in "${pkgs[@]}"; do # for pkg in "${pkgs[@]}"; do
spin bold yellow "Installing $pkg" # spin bold yellow "Installing $pkg"
if run --err err --out out pkg-install "$pkg"; then # if run --err err --out out pkg-install "$pkg"; then
check "Installed $pkg" # check "Installed $pkg"
line # line
else # else
throw "$pkg could not get installed.." # throw "$pkg could not get installed.."
echo_error "${err:-}" # echo_error "${err:-}"
echo_note "${out:-}" # echo_note "${out:-}"
line # line
fi # fi
done # done
} # }
main() { main() {
local err out local err out
@ -119,19 +118,22 @@ main() {
check "Dependency list generated!" check "Dependency list generated!"
pen red bold "There are ${#deplist[@]} items to install.." pen red bold "There are ${#deplist[@]} items to install.."
# local pkgs="$@" # local pkgs="$@"
for ((i = 0; i < "${#deplist[@]}"; i++)); do
for pkg in "${deplist[@]}"; do for pkg in "${deplist[@]}"; do
spin bold yellow "Installing $pkg" spin bold yellow "Installing $pkg"
if run --err err --out out pkg-install "$pkg"; then if run --err err --out out pkg-install "$pkg"; then
check "Installed $pkg" check "Installed $pkg"
line line
else else
check "$pkg could not get installed.." check "$pkg could not get installed.."
echo_error "${err:-}" echo_error "${err:-}"
echo_note "${out:-}" echo_note "${out:-}"
line line
fi continue
fi
done
done done
fi fi
# case "$distro" in # case "$distro" in