Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confirmation prompt for down, prune and recreate commands #440

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions fablo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,22 @@ generateNetworkConfig() {
("$fablo_target/hooks/post-generate.sh")
}

confirmationPrompt() {
for arg in "$@"; do
if [ "$arg" = "--silent" ]; then
return 0
fi
done

read -p "Are you sure you want to prune the network? This action will stop and remove all running Fabric containers. (y/n): " answer
if [ "$answer" != "y" ]; then
echo "Operation aborted."
exit 1
fi
}

networkPrune() {
confirmationPrompt "$@"
if [ -f "$FABLO_TARGET/fabric-docker.sh" ]; then
"$FABLO_TARGET/fabric-docker.sh" down
fi
Expand Down Expand Up @@ -293,10 +308,10 @@ elif [ "$COMMAND" = "up" ]; then
networkUp "$2"

elif [ "$COMMAND" = "prune" ]; then
networkPrune
networkPrune "$2"

elif [ "$COMMAND" = "recreate" ]; then
networkPrune
networkPrune "$2"
networkUp "$2"

elif [ "$COMMAND" = "snapshot" ]; then
Expand All @@ -306,5 +321,8 @@ elif [ "$COMMAND" = "restore" ]; then
restoreSnapshot "$2" "${3:-""}"

else
if [ "$COMMAND" = "down" ]; then
confirmationPrompt "$2"
fi
executeFabloCommand "$COMMAND" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
fi
Loading