ask_lib is a small Python package available on PyPi that lets you ask user's confirmation from a CLI.
You can take a look to the documentation, hosted by ReadTheDocs.
- Simple API.
- No dependencies.
- Well tested.
- Featuring CI.
pip install ask_lib
# Or, if you are using poetry
poetry add ask_lib
from ask_lib import ask, AskResult
to_remove = "file.txt"
if ask("Are you sure to delete this file ?", AskResult.NO):
os.remove(to_remove)
import os
import sys
from ask_lib import ask, AskResult
yes_to_all = AskFlag.YES_TO_ALL if "-force" in sys.argv else None
to_remove = "file.txt"
if ask("Are you sure to delete this file ?", flag=yes_to_all):
os.remove(to_remove)