From c0676e3fa3b79cbf61d9f544f2ac7f97252b6793 Mon Sep 17 00:00:00 2001 From: Aanand Prasad Date: Tue, 31 Dec 2013 13:42:58 +0000 Subject: [PATCH] Add confirmation prompt to 'fig rm' --- fig/cli/main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fig/cli/main.py b/fig/cli/main.py index f6714f1e..7028cf29 100644 --- a/fig/cli/main.py +++ b/fig/cli/main.py @@ -9,6 +9,7 @@ from ..project import NoSuchService from .command import Command from .formatter import Formatter from .log_printer import LogPrinter +from .utils import yesno from docker.client import APIError from .errors import UserError @@ -201,7 +202,15 @@ class TopLevelCommand(Command): Usage: rm [SERVICE...] """ - self.project.remove_stopped(service_names=options['SERVICE']) + all_containers = self.project.containers(service_names=options['SERVICE'], stopped=True) + stopped_containers = [c for c in all_containers if not c.is_running] + + if len(stopped_containers) > 0: + print "Going to remove", list_containers(stopped_containers) + if yesno("Are you sure? [yN] ", default=False): + self.project.remove_stopped(service_names=options['SERVICE']) + else: + print "No stopped containers" def logs(self, options): """