jp (base): new confirmOrQuit helper method to ask confirmation to user, and quit if he cancel

This commit is contained in:
Goffi 2018-03-31 18:21:56 +02:00
commit 60eab27872

View file

@ -140,11 +140,7 @@ class NodeDelete(base.CommandBase):
else:
message = _(u"Are you sure to delete node [{node_id}] on service [{service}] ?").format(
node_id=self.args.node, service=self.args.service)
res = raw_input("{} (y/N)? ".format(message))
if res not in ("y", "Y"):
self.disp(_(u"node deletion cancelled"))
self.host.quit(2)
self.host.confirmOrQuit(message, _(u"node deletion cancelled"))
self.host.bridge.psNodeDelete(
self.args.service,
@ -572,10 +568,7 @@ class Delete(base.CommandBase):
self.parser.error(_(u"You need to specify an item to delete"))
if not self.args.force:
message = _(u"Are you sure to delete item {item_id} ?").format(item_id=self.args.item)
res = raw_input("{} (y/N)? ".format(message))
if res not in ("y", "Y"):
self.disp(_(u"Item deletion cancelled"))
self.host.quit(2)
self.host.confirmOrQuit(message, _(u"item deletion cancelled"))
self.host.bridge.psRetractItem(
self.args.service,
self.args.node,