diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/gc | 46 |
1 files changed, 26 insertions, 20 deletions
@@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - gc [TYPE] + gc [TYPE...] gc -h EOF } @@ -35,9 +35,9 @@ help() { $ gc - Cleanup tmpdir: + Cleanup trash and tmpdir: - $ gc tmpdir + $ gc trash tmpdir EOF } @@ -139,28 +139,34 @@ gc_vcs() { } -gc_all() { - set -x - gc_guix - gc_nix - gc_trash - gc_tmpdir - gc_docker - gc_vcs - set +x -} +TYPES=' +guix +nix +trash +tmpdir +docker +vcs +' -TYPE="${1:-all}" -CMD=gc_"$TYPE" -if ! command -v "$CMD" >/dev/null; then - printf 'Invalid TYPE: "%s".\n\n' "$TYPE" >&2 - usage >&2 - exit 2 +if [ $# -eq 0 ]; then + set -- $TYPES fi +for type in "$@"; do + CMD=gc_"$type" + if ! command -v "$CMD" >/dev/null; then + printf 'Invalid TYPE: "%s".\n\n' "$type" >&2 + usage >&2 + exit 2 + fi +done BEFORE="$(disk)" -"$CMD" +for type in "$@"; do + set -x + "$CMD" + { set +x; } 2>/dev/null +done AFTER="$(disk)" cat <<-EOF |