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__,
|
parser = QubesArgumentParser(description=__doc__,
|
||||||
want_app=True,
|
want_app=True,
|
||||||
vmname_nargs='+')
|
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
|
def main(args=None, app=None): # pylint: disable=missing-docstring
|
||||||
args = parser.parse_args(args, app=app)
|
args = parser.parse_args(args, app=app)
|
||||||
|
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:
|
for vm in args.domains:
|
||||||
del args.app.domains[vm.name]
|
del args.app.domains[vm.name]
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
else:
|
||||||
|
print("Remove cancelled.")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user