mirror of
https://github.com/shadoll/just-commons.git
synced 2026-08-28 19:43:13 +00:00
Replace manual confirmations with [confirm] attribute in destructive commands
- Add [confirm] attribute to all destructive operations: - volumes-clean-all, volumes-remove, volumes-remove-pattern - postgres-drop-database, postgres-restore - mysql-drop-database, mysql-restore - Remove manual read -p confirmations and conditional logic - Simplifies code and uses Just's built-in confirmation system - Ensures consistent confirmation behavior across all destructive operations This provides better UX and cleaner code using Just's native features.
This commit is contained in:
+3
-19
@@ -2,6 +2,7 @@
|
||||
|
||||
# Clean all volumes used by compose file (DESTRUCTIVE!)
|
||||
[group('volumes')]
|
||||
[confirm]
|
||||
volumes-clean-all compose-file="":
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
@@ -23,13 +24,6 @@ volumes-clean-all compose-file="":
|
||||
$compose_cmd $file_arg config --volumes 2>/dev/null || echo "Cannot list volumes from compose file"
|
||||
echo ""
|
||||
|
||||
read -p "Are you sure? Type 'yes' to continue: " confirm
|
||||
|
||||
if [ "$confirm" != "yes" ]; then
|
||||
echo "Aborted"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "{{BLUE}}Stopping services...{{NC}}"
|
||||
$compose_cmd $file_arg down
|
||||
|
||||
@@ -40,6 +34,7 @@ volumes-clean-all compose-file="":
|
||||
|
||||
# Remove specific volume by name (DESTRUCTIVE!)
|
||||
[group('volumes')]
|
||||
[confirm]
|
||||
volumes-remove volume_name:
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
@@ -62,12 +57,6 @@ volumes-remove volume_name:
|
||||
|
||||
echo -e "{{RED}}⚠️ WARNING: This will DELETE VOLUME DATA!{{NC}}"
|
||||
echo -e "{{YELLOW}}This will remove volume: $volume_name{{NC}}"
|
||||
read -p "Are you sure? Type 'yes' to continue: " confirm
|
||||
|
||||
if [ "$confirm" != "yes" ]; then
|
||||
echo "Aborted"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "{{BLUE}}Removing volume: $volume_name{{NC}}"
|
||||
$runtime volume rm "$volume_name" 2>/dev/null || true
|
||||
@@ -76,6 +65,7 @@ volumes-remove volume_name:
|
||||
|
||||
# Remove volumes matching pattern (DESTRUCTIVE!)
|
||||
[group('volumes')]
|
||||
[confirm]
|
||||
volumes-remove-pattern pattern:
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
@@ -102,12 +92,6 @@ volumes-remove-pattern pattern:
|
||||
echo -e "{{YELLOW}}Volumes matching pattern '$pattern':{{NC}}"
|
||||
echo "$matching_volumes"
|
||||
echo ""
|
||||
read -p "Are you sure? Type 'yes' to continue: " confirm
|
||||
|
||||
if [ "$confirm" != "yes" ]; then
|
||||
echo "Aborted"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "{{BLUE}}Removing matching volumes...{{NC}}"
|
||||
echo "$matching_volumes" | while IFS= read -r volume; do
|
||||
|
||||
Reference in New Issue
Block a user