diff --git a/qubesadmin/tools/qvm_remove.py b/qubesadmin/tools/qvm_remove.py index b5a3ad0..0e9ddb0 100644 --- a/qubesadmin/tools/qvm_remove.py +++ b/qubesadmin/tools/qvm_remove.py @@ -28,14 +28,26 @@ from qubesadmin.tools import QubesArgumentParser parser = QubesArgumentParser(description=__doc__, want_app=True, vmname_nargs='+') +parser.add_argument("--yes", action="store_true", dest="no_confirm", + default=False, help="Do not prompt for confirmation") + def main(args=None, app=None): # pylint: disable=missing-docstring args = parser.parse_args(args, app=app) - for vm in args.domains: - del args.app.domains[vm.name] + go_ahead = "" + if not args.no_confirm: + print("This will completely remove the selected VM(s)...") + go_ahead = input("Are you sure? [y/N] ").upper() + + if args.no_confirm or go_ahead == "Y": + for vm in args.domains: + del args.app.domains[vm.name] + return 0 + else: + print("Remove cancelled.") + return 1 - return 0 if __name__ == '__main__':