Add --yes option and confirm prompt.
This commit is contained in:
parent
c82d5b0a73
commit
ed11346977
@ -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__':
|
||||
|
Loading…
Reference in New Issue
Block a user