diff --git a/sat_frontends/jp/base.py b/sat_frontends/jp/base.py index d2c2db0e..b394e12c 100644 --- a/sat_frontends/jp/base.py +++ b/sat_frontends/jp/base.py @@ -685,11 +685,15 @@ class Jp(object): loop.add_reader(sys.stdin, self._read_stdin, stdin_fut) return await stdin_fut + async def confirm(self, message): + """Request user to confirm action, return answer as boolean""" + res = await self.ainput(f"{message} (y/N)? ") + return res in ("y", "Y") + async def confirmOrQuit(self, message, cancel_message=_("action cancelled by user")): """Request user to confirm action, and quit if he doesn't""" - - res = await self.ainput(f"{message} (y/N)? ") - if res not in ("y", "Y"): + confirmed = await self.confirm(message) + if not confirmed: self.disp(cancel_message) self.quit(C.EXIT_USER_CANCELLED)