def confirm(prompt, yes=True):
"""Confirm with user input
:param prompt: Question or text that the user gets.
:type prompt: str
:param yes: If yes should be the default.
:type yes: bool
:returns: True if go ahead, False if stop
:rtype: bool
"""
import prompt_toolkit
result = prompt_toolkit.prompt(
prompt + ' (%s): ' % ('Y/n' if yes else 'y/N')
)
if yes:
return result not in ['N', 'n']
else:
return result not in ['Y', 'y']
评论列表
文章目录