Add shorthands to clean loose files/processes.

This commit is contained in:
Alejandro Cabeza Romero 2026-06-12 16:03:23 +02:00
parent c0079fdd6f
commit 7cd7355fe8
No known key found for this signature in database
GPG Key ID: DA3D14AE478030FD

52
justfile Normal file
View File

@ -0,0 +1,52 @@
# Usage:
# just clean # prompts before each step
# just clean -y # skips all prompts
# just clean --yes # skips all prompts
clean *args:
#!/usr/bin/env bash
skip_confirmation=0
case "{{args}}" in
*-y*|*--yes*) skip_confirmation=1 ;;
esac
confirm() {
[ "$skip_confirmation" = "1" ] && return 0
read -r -n 1 -p "$1 [y/N] " ans
echo
case "$ans" in
[yY]) return 0 ;;
*) return 1 ;;
esac
}
remove() {
if [ -e "$1" ]; then
confirm "Remove $1?" && { echo "Removing $1"; rm -rf "$1"; }
else
echo "Already removed: $1"
fi
}
if pgrep -x logos > /dev/null; then
confirm "Kill 'logos' process?" && pkill logos
else
echo "Already killed"
fi
remove state
shopt -s nullglob
timestamp_files=( [0-9]* )
shopt -u nullglob
if [ ${#timestamp_files[@]} -gt 0 ]; then
confirm "Remove ${timestamp_files[*]}?" && { echo "Removing ${timestamp_files[*]}"; rm -rf "${timestamp_files[@]}"; }
else
echo "Already removed: [0-9]* (no matching files)"
fi
remove keystore.yaml
remove user_config.yaml
run: (clean "-y")
nix run