Skip to content

Commit

Permalink
added the silent option for the commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket-0510 committed Apr 9, 2024
1 parent c1a6f5f commit 215b83e
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions fablo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,21 @@ generateNetworkConfig() {
}

confirmationPrompt() {
if [ "$1" != "--silent" ]; then
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
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 "$1"
confirmationPrompt "$@"

if [ -f "$FABLO_TARGET/fabric-docker.sh" ]; then
"$FABLO_TARGET/fabric-docker.sh" down
Expand Down Expand Up @@ -307,10 +310,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 @@ -320,5 +323,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 215b83e

Please sign in to comment.