mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 06:12:34 +00:00
feat: Prep for new run syntax.
This commit is contained in:
50
run
50
run
@@ -23,6 +23,7 @@ uninstall="0"
|
||||
while [[ $# -gt 0 ]]; do
|
||||
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
|
||||
if [[ "$1" =~ ^--dry ]]; then
|
||||
dry_run="1"
|
||||
@@ -32,10 +33,13 @@ while [[ $# -gt 0 ]]; do
|
||||
# Handle an --install argument (default)
|
||||
elif [[ ! "$1" =~ ^--i ]]; then
|
||||
grep="$1"
|
||||
else
|
||||
grep="$1"
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
# TODO: Setup proper logging using '$SCRIPTS/hypr/logging'
|
||||
log() {
|
||||
if [[ $dry_run == "1" ]]; then
|
||||
echo "[DRY_RUN]: $1"
|
||||
@@ -44,6 +48,7 @@ log() {
|
||||
fi
|
||||
}
|
||||
|
||||
# TODO: Remove.
|
||||
run() {
|
||||
local script=$1
|
||||
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 ##############################
|
||||
|
||||
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
|
||||
if basename $s | grep -vq "$grep"; then
|
||||
@@ -75,8 +119,10 @@ for s in $runs_dir; do
|
||||
fi
|
||||
|
||||
if [[ $uninstall == "1" ]]; then
|
||||
# TODO: Use function instead.
|
||||
run $s --uninstall
|
||||
else
|
||||
# TODO: Use function instead.
|
||||
run $s --install
|
||||
fi
|
||||
done
|
||||
|
||||
9
runs/before/yay
Executable file
9
runs/before/yay
Executable 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
|
||||
Reference in New Issue
Block a user