feat: Prep for new run syntax.

This commit is contained in:
2025-11-09 20:44:40 -05:00
parent af7b46efa5
commit 381a0450e5
2 changed files with 96 additions and 41 deletions

50
run
View File

@@ -23,6 +23,7 @@ uninstall="0"
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
echo "ARG: \"$1\"" echo "ARG: \"$1\""
# TODO: Fix some of these arguments, should we add a '--grep' option, should '[un]install' be args / not options?
# Handle a --dry or --dry-run argument # Handle a --dry or --dry-run argument
if [[ "$1" =~ ^--dry ]]; then if [[ "$1" =~ ^--dry ]]; then
dry_run="1" dry_run="1"
@@ -32,10 +33,13 @@ while [[ $# -gt 0 ]]; do
# Handle an --install argument (default) # Handle an --install argument (default)
elif [[ ! "$1" =~ ^--i ]]; then elif [[ ! "$1" =~ ^--i ]]; then
grep="$1" grep="$1"
else
grep="$1"
fi fi
shift shift
done done
# TODO: Setup proper logging using '$SCRIPTS/hypr/logging'
log() { log() {
if [[ $dry_run == "1" ]]; then if [[ $dry_run == "1" ]]; then
echo "[DRY_RUN]: $1" echo "[DRY_RUN]: $1"
@@ -44,6 +48,7 @@ log() {
fi fi
} }
# TODO: Remove.
run() { run() {
local script=$1 local script=$1
local flag=$2 local flag=$2
@@ -62,11 +67,50 @@ run() {
} }
install() {
local file line pkg
file=${1:-""}
# Early out if the file is not readable.
[[ ! -r $file ]] && exit 1
# Loop over lines in the file and install the packages.
while read -r line; do
# Skip lines that begin with '#' (comments)
if [[ ! $line =~ ^# ]]; then
# Remove any inline comments.
pkg=${line%% \#*}
# TODO: We should log something here??
[[ $dry_run == "0" ]] && yay -S --noconfirm --needed "$pkg"
fi
done <"$file"
}
uninstall() {
local file line pkg
file=${1:-""}
# Early out if the file is not readable.
[[ ! -r $file ]] && exit 1
# Loop over lines in the file and uninstall the packages.
while read -r line; do
# Skip lines that begin with '#' (comments)
if [[ ! $line =~ ^# ]]; then
# Remove any inline comments.
pkg=${line%% \#*}
# TODO: We should log something here??
[[ $dry_run == "0" ]] && yay -Rns "$pkg"
fi
done <"$file"
}
############################## MAIN ############################## ############################## MAIN ##############################
log "RUN: env: $env -- grep: $grep" log "RUN: -- grep: $grep"
runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -executable) #runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -type f) # TODO: keep
runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -executable) # TODO: remove.
for s in $runs_dir; do for s in $runs_dir; do
if basename $s | grep -vq "$grep"; then if basename $s | grep -vq "$grep"; then
@@ -75,8 +119,10 @@ for s in $runs_dir; do
fi fi
if [[ $uninstall == "1" ]]; then if [[ $uninstall == "1" ]]; then
# TODO: Use function instead.
run $s --uninstall run $s --uninstall
else else
# TODO: Use function instead.
run $s --install run $s --install
fi fi
done done

9
runs/before/yay Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
if ! command -v yay >/dev/null 2>&1; then
sudo pacman -S --noconfirm --needed git base-devel
git clone https://aur.archlinux.org/yay.git ~/yay
cd ~/yay
makepkg -si
rm -rf ~/yay
fi