From 7a699d2181e1ca6902c9c2f1465f2b51d7a58598 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 22 Sep 2025 19:11:31 +0000 Subject: [PATCH] sane-wipe: implement `--verbose` flag --- pkgs/by-name/sane-scripts/src/sane-wipe | 71 +++++++++++++++---------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/pkgs/by-name/sane-scripts/src/sane-wipe b/pkgs/by-name/sane-scripts/src/sane-wipe index 3d88ef341..df14a8c4c 100755 --- a/pkgs/by-name/sane-scripts/src/sane-wipe +++ b/pkgs/by-name/sane-scripts/src/sane-wipe @@ -1,16 +1,47 @@ #!/usr/bin/env nix-shell #!nix-shell -i bash -p bash -p dconf -p libsecret -p procps -p systemdMinimal +set -eu + usage() { - echo "usage: sane-wipe RESOURCE" + echo "usage: sane-wipe [--verbose] RESOURCE [RESOURCE ...]" echo "RESOURCE:" - echo " browser: kill and remove cache for firefox, chromium, brave, etc" + echo " browser: kill and remove cache for firefox, epiphany, chromium, brave, etc" echo " dino: remove auth and data for Dino XMPP messenger" echo " flare: remove auth and data for flare-signal messenger" echo " fractal: remove auth and data for fractal matrix messenger" echo " rofi: remove rofi .desktop entry cache and force it to recompute entries" } +resources=() +VERBOSE= +parseArgs() { + while [[ $# -ge 1 ]]; do + local arg=$1 + shift + case "$arg" in + (browser|dino|flare|fractal|rofi) + resources+=("$arg") + ;; + (--help) + usage + exit 0 + ;; + (--verbose) + VERBOSE=1 + ;; + *) + usage + exit 1 + ;; + esac + done + + if [[ ${#resources[@]} -eq 0 ]]; then + usage + exit 1 + fi +} wipe_browser() { # remove chromium/epiphany/firefox/librewolf artifacts @@ -71,29 +102,15 @@ wipe_rofi() { rm -f ~/.cache/rofi/rofi-drun-desktop.cache } +main() { + if [ -n "$VERBOSE" ]; then + set -x + fi -case "$1" in - (browser) - wipe_browser - ;; - (dino) - wipe_dino - ;; - (flare) - wipe_flare - ;; - (fractal) - wipe_fractal - ;; - (rofi) - wipe_rofi - ;; - (--help) - usage - exit 0 - ;; - *) - usage - exit 1 - ;; -esac + for r in "${resources[@]}"; do + "wipe_$r" + done +} + +parseArgs "$@" +main