mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-11-14 04:57:53 -06:00
26 lines
470 B
Python
26 lines
470 B
Python
#% extends "py-script.mk" %#
|
|
#% block name %#confirm#% endblock %#
|
|
#% block script %#
|
|
|
|
import sys
|
|
|
|
##- '$(ansi_py)' -##
|
|
|
|
|
|
def confirm():
|
|
"""
|
|
Ask user to enter Y or N (case-insensitive).
|
|
:return: True if the answer is Y.
|
|
:rtype: bool
|
|
"""
|
|
answer = ""
|
|
while answer not in ["y", "n"]:
|
|
answer = input(f"""$(2) {a.b_red}[Y/n]{a.end} """).lower()
|
|
return answer == "y"
|
|
|
|
|
|
if confirm():
|
|
sys.exit(0)
|
|
else:
|
|
sys.exit(1)
|
|
#% endblock %#
|