Skip to content

Commit

Permalink
added the confirmation prompt for down, prune and recreate commands
Browse files Browse the repository at this point in the history
Signed-off-by: Sanket <[email protected]>
  • Loading branch information
Sanket-0510 committed Apr 9, 2024
1 parent 3aa4587 commit bf494ec
Showing 1 changed file with 20 additions and 2 deletions.
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

0 comments on commit bf494ec

Please sign in to comment.