From f5ff7bfd611fdcccf41918728827d9fef168cf13 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Sat, 26 Oct 2024 19:40:08 +0300
Subject: [PATCH] Add a remove command to wb.

Sometimes I change versions of podman and I need to remove the container
and image and recreate them.
---
 Documents/bin/wb | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/Documents/bin/wb b/Documents/bin/wb
index 9cd4877..c35a4a4 100755
--- a/Documents/bin/wb
+++ b/Documents/bin/wb
@@ -108,6 +108,22 @@ in_toolbox() {
     [ "$(hostname)" = 'toolbox' ]
 }
 
+remove() {
+    not_from_toolbox
+    if container_exists
+    then
+        podman container rm --force "$CONTAINER"
+    else
+        echo "Container not found." >&2
+    fi
+    if image_exists
+    then
+        podman image rm --force "$IMAGE"
+    else
+        echo "Image not found." >&2
+    fi
+}
+
 if [ "$#" -eq 0 ]
 then
     run
@@ -115,11 +131,12 @@ fi
 
 case "${1:-}" in
     -d|--dry-update) dry_update;;
-    -u|--update) update;;
-    -l|--list) list;;
     -h|--help) usage;;
-    -s|--kill-server) kill_server;;
     -i|--in-workbench) in_toolbox;;
     -k|--kill) _kill "${2:-}";;
+    -l|--list) list;;
+    -r|--rm|--remove) remove;;
+    -s|--kill-server) kill_server;;
+    -u|--update) update;;
     *) run "$1";;
 esac
-- 
GitLab